OpenSDN source code
index_resource.h
Go to the documentation of this file.
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_resource_hpp
7 #define vnsw_agent_index_resource_hpp
8 
10 #include "resource_cmn.h"
11 class ResourceTable;
12 class ResourceManager;
13 class ResourceKey;
14 class ResourceData;
15 
16 class IndexResourceKey : public ResourceKey {
17 public:
19  virtual ~IndexResourceKey();
20 
21  virtual const std::string ToString() {return "";}
22  virtual bool IsLess(const ResourceKey &rhs) const = 0;
23  virtual void Backup(ResourceData *data, uint16_t op) = 0;
24 
25 };
26 
28 public:
29  //Used by allocation & restore of resource
31  uint32_t index);
32  virtual ~IndexResourceData();
33 
34  uint32_t index() const;
35  virtual const std::string ToString() {return "";}
36 private:
37  uint32_t index_;
39 };
40 // This Class is responsible for allocating the unique resource index
41 // for each key we are adding to the table.
43 public:
45  virtual ~IndexResourceTable();
46  void ReserveIndex(uint32_t index);
47  void ReleaseIndex(uint32_t index);
48  void Release(uint32_t index);
50  virtual const std::string ToString() {return "";}
51 
52  uint32_t AllocateIndex(ResourceKeyPtr key);
53  void RestoreIndex(uint32_t index, ResourceKeyPtr key);
54  void RestoreKey(KeyPtr key, DataPtr data);
55  void ReleaseKey(KeyPtr key, DataPtr data);
56 
57 private:
60 };
61 
62 #endif
virtual const std::string ToString()
DISALLOW_COPY_AND_ASSIGN(IndexResourceData)
IndexResourceData(ResourceManager *rm, uint32_t index)
virtual ~IndexResourceData()
uint32_t index() const
virtual bool IsLess(const ResourceKey &rhs) const =0
virtual ~IndexResourceKey()
virtual void Backup(ResourceData *data, uint16_t op)=0
virtual const std::string ToString()
IndexResourceKey(ResourceManager *rm, Resource::Type resource_key_type)
void RestoreKey(KeyPtr key, DataPtr data)
void RestoreIndex(uint32_t index, ResourceKeyPtr key)
DISALLOW_COPY_AND_ASSIGN(IndexResourceTable)
void Release(uint32_t index)
void ReserveIndex(uint32_t index)
virtual ~IndexResourceTable()
IndexResourceTable(ResourceManager *rm)
virtual ResourceTable::DataPtr AllocateData(ResourceKeyPtr key)
void ReleaseKey(KeyPtr key, DataPtr data)
IndexVectorResource< ResourceKeyPtr > index_vector_
void ReleaseIndex(uint32_t index)
uint32_t AllocateIndex(ResourceKeyPtr key)
virtual const std::string ToString()
ResourceManager * rm()
boost::shared_ptr< ResourceData > DataPtr
ResourceTable::KeyPtr ResourceKeyPtr
boost::shared_ptr< ResourceKey > KeyPtr