Manak  2.0.0
object_store.hpp
Go to the documentation of this file.
1 #ifndef _MANAK_UTIL_OBJECT_STORE_HPP_INCLUDED
2 #define _MANAK_UTIL_OBJECT_STORE_HPP_INCLUDED
3 
4 #include <map>
5 #include <string>
6 #include <list>
7 #include <iostream>
8 
9 #include "macro_utils.hpp"
10 
11 namespace manak
12 {
13 namespace utils
14 {
15 
16 class ObjectStore : public std::map<std::string, void*>
17 {
18  public:
20 
21  MANAK_INLINE void* Get(const std::string& name) const;
22 
23  MANAK_INLINE void* RGet(const std::string& name);
24 
25  MANAK_INLINE bool Erase(const std::string& name);
26 
27  MANAK_INLINE void Insert(const std::string& name, void* obj,
28  const std::string& group_name = "");
29 
30  MANAK_INLINE bool EraseGroup(const std::string& group_name);
31 
32  private:
33  std::map<std::string, std::list<std::string>> m_groups;
34 };
35 
36 MANAK_INLINE std::ostream& operator<<(std::ostream& s, const ObjectStore& os);
37 
38 }
39 }
40 
41 #ifndef MANAK_USE_DYN_LINK
42 #include "object_store.cpp"
43 #endif // MANAK_USE_DYN_LINK
44 
45 #endif // _MANAK_UTIL_OBJECT_STORE_HPP_INCLUDED
bool EraseGroup(const std::string &group_name)
void * RGet(const std::string &name)
static ObjectStore & GetGlobalObjectStore()
#define MANAK_INLINE
Check if user has opt for dynamic linking.
Definition: macro_utils.hpp:25
std::ostream & operator<<(std::ostream &s, const ObjectStore &os)
bool Erase(const std::string &name)
std::map< std::string, std::list< std::string > > m_groups
void Insert(const std::string &name, void *obj, const std::string &group_name="")
void * Get(const std::string &name) const