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 18 : IndexVectorResource() { 18 18 : } 19 18 : virtual ~IndexVectorResource() { 20 18 : } 21 : 22 : //index allocation from index table 23 305 : uint32_t AllocIndex(Object entry) { 24 305 : return index_table_.Insert(entry); 25 : } 26 : 27 5053 : uint32_t InsertAtIndex(uint32_t index, Object entry) { 28 5053 : 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 353 : void FreeIndex(uint32_t index) { 35 353 : index_table_.Remove(index); 36 353 : } 37 : 38 307 : Object FindIndex(size_t index) { 39 307 : return index_table_.At(index); 40 : } 41 : 42 : private: 43 : IndexVector<Object> index_table_; 44 : }; 45 : #endif //index_vector_resource