Changes in src/Actions/ActionRegistry.cpp [112b09:b2d8d0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.cpp
r112b09 rb2d8d0 1 1 /* 2 * ActionRegistry.cpp2 * Registry<Action>.cpp 3 3 * 4 4 * Created on: Jan 7, 2010 … … 9 9 10 10 #include "Actions/ActionRegistry.hpp" 11 #include "Actions/Action.hpp" 11 #include "Patterns/Singleton_impl.hpp" 12 #include "Patterns/Registry_impl.hpp" 12 13 13 #include "Patterns/Singleton_impl.hpp" 14 /** Constructor for class ActionRegistry. 15 */ 16 ActionRegistry::ActionRegistry() 17 {} 14 18 15 #include <string> 16 #include "Helpers/Assert.hpp" 17 #include <iostream> 19 /** Destructor for class ActionRegistry. 20 */ 21 ActionRegistry::~ActionRegistry() 22 {} 18 23 19 using namespace std; 20 21 ActionRegistry::ActionRegistry() 24 /** Just passes on call to Registry<Action>::getByName(). 25 * \param name name of Action 26 * \return pointer to Action 27 */ 28 Action* ActionRegistry::getActionByName(const std::string name) 22 29 { 30 return getByName(name); 23 31 } 24 32 25 ActionRegistry::~ActionRegistry() 33 /** Just passes on call to Registry<Action>::isPresentByName(). 34 * \param name name of Action 35 * \return true - Action instance present, false - not 36 */ 37 bool ActionRegistry::isActionPresentByName(const std::string name) 26 38 { 27 map<const string,Action*>::iterator iter; 28 for(iter=actionMap.begin();iter!=actionMap.end();++iter) { 29 delete iter->second; 30 } 31 actionMap.clear(); 32 } 33 34 Action* ActionRegistry::getActionByName(const std::string name){ 35 map<const string,Action*>::iterator iter; 36 iter = actionMap.find(name); 37 ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry"); 38 return iter->second; 39 } 40 41 void ActionRegistry::registerAction(Action* action){ 42 pair<map<const string,Action*>::iterator,bool> ret; 43 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 44 ASSERT(ret.second,"Two actions with the same name added to registry"); 45 } 46 47 void ActionRegistry::unregisterAction(Action* action){ 48 actionMap.erase(action->getName()); 49 } 50 51 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 52 { 53 return actionMap.begin(); 54 } 55 56 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 57 { 58 return actionMap.end(); 39 return isPresentByName(name); 59 40 } 60 41 61 42 CONSTRUCT_SINGLETON(ActionRegistry) 43 CONSTRUCT_REGISTRY(Action)
Note:
See TracChangeset
for help on using the changeset viewer.