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