Line data Source code
1 : /* 2 : * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_index_vector_resource_hpp 6 : #define vnsw_agent_index_vector_resource_hpp 7 : 8 : #include <cmn/agent_cmn.h> 9 : #include <cmn/agent.h> 10 : #include <cmn/index_vector.h> 11 : 12 : 13 : template<typename Object> 14 : // This Class is to do Index Allocation. 15 : class IndexVectorResource { 16 : public: 17 6 : IndexVectorResource() { 18 6 : } 19 6 : virtual ~IndexVectorResource() { 20 6 : } 21 : 22 : //index allocation from index table 23 111 : uint32_t AllocIndex(Object entry) { 24 111 : return index_table_.Insert(entry); 25 : } 26 : 27 16 : uint32_t InsertAtIndex(uint32_t index, Object entry) { 28 16 : return index_table_.InsertAtIndex(index, entry); 29 : } 30 : 31 : void UpdateIndex(uint32_t index, Object entry) { 32 : return index_table_.Update((index), entry); 33 : } 34 127 : void FreeIndex(uint32_t index) { 35 127 : index_table_.Remove(index); 36 127 : } 37 : 38 111 : Object FindIndex(size_t index) { 39 111 : return index_table_.At(index); 40 : } 41 : 42 : private: 43 : IndexVector<Object> index_table_; 44 : }; 45 : #endif //index_vector_resource