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