Changes in src/Patterns/Registry.hpp [b2d8d0:e4afb4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Registry.hpp
rb2d8d0 re4afb4 2 2 * Registry.hpp 3 3 * 4 * Based on Registry<Action>by Till Crueger.4 * Based on initial ActionRegistry code by Till Crueger. 5 5 * 6 6 * The registry pattern is basically just a singleton map, wherein instantiations … … 21 21 * <h1> Registry Howto </h1> 22 22 * 23 * The registry is a class where instances of other classes are stored and be retrieved24 * when desired. For this purpose a registry should always be a singleton (i.e. use both25 * this registry and the singleton pattern to declare a registry class). It basically26 * is simply a singleton container of a map, where the pointers to the class instances are27 * stored by a string key and can be retrieved thereby.23 * The Registry is a class where instances of other classes are stored and be retrieved 24 * by a string token when desired. For this purpose a Registry should always be a singleton 25 * (i.e. use both this Registry and the Singleton pattern to declare a Registry class). It 26 * basically is simply a singleton container of a map, where the pointers to the class 27 * instances are stored by a string key and can be retrieved thereby. 28 28 * 29 * The available functions are, if your class to be stored in registry is foo : 29 * The available functions are as follows if your class instances to be stored in Registry 30 * are of type 'foo': 30 31 * 31 32 * - <code>foo* Registry<foo>::getByName()</code> : returns the instance of a specific … … 58 59 ~Registry(); 59 60 60 T* getByName(const std::string name); 61 bool isPresentByName(const std::string name); 61 typedef typename std::map<const std::string,T*> instance_map; 62 typedef typename std::map<const std::string,T*>::iterator iterator; 63 typedef typename std::map<const std::string,T*>::const_iterator const_iterator; 64 65 T* getByName(const std::string name) const; 66 bool isPresentByName(const std::string name) const; 62 67 void registerInstance(T*); 63 68 void unregisterInstance(T*); 69 void cleanup(); 64 70 65 typename std::map<const std::string,T*>::iterator getBeginIter();66 typename std::map<const std::string,T*>::const_iterator getBeginIter() const;67 typename std::map<const std::string,T*>::iterator getEndIter();68 typename std::map<const std::string,T*>::const_iterator getEndIter() const;71 iterator getBeginIter(); 72 const_iterator getBeginIter() const; 73 iterator getEndIter(); 74 const_iterator getEndIter() const; 69 75 70 76 private: 71 typename std::map<const std::string,T*>InstanceMap;77 instance_map InstanceMap; 72 78 }; 73 79
Note:
See TracChangeset
for help on using the changeset viewer.