Changes in src/Actions/ActionRegistry.cpp [d0fbec:112b09]
- File:
-
- 1 edited
-
src/Actions/ActionRegistry.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.cpp
rd0fbec r112b09 19 19 using namespace std; 20 20 21 /** Constructor for class ActionRegistry.22 */23 21 ActionRegistry::ActionRegistry() 24 22 { 25 23 } 26 24 27 /** Destructor for class ActionRegistry.28 */29 25 ActionRegistry::~ActionRegistry() 30 26 { … … 36 32 } 37 33 38 /** Returns pointer to an action named by \a name.39 * \param name name of action40 * \return pointer to Action41 */42 34 Action* ActionRegistry::getActionByName(const std::string name){ 43 35 map<const string,Action*>::iterator iter; … … 47 39 } 48 40 49 /** States whether action is present or not.50 * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.51 * \param name name of action52 * \return true - Action present, false - Action absent53 */54 bool ActionRegistry::isActionByNamePresent(const std::string name){55 map<const string,Action*>::iterator iter;56 iter = actionMap.find(name);57 return iter!=actionMap.end();58 }59 60 /** Registers an Action with the ActionRegistry.61 * \param *action pointer to Action.62 */63 41 void ActionRegistry::registerAction(Action* action){ 64 42 pair<map<const string,Action*>::iterator,bool> ret; 65 //cout << "Trying to register action with name " << action->getName() << "." << endl;66 43 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 67 44 ASSERT(ret.second,"Two actions with the same name added to registry"); 68 45 } 69 46 70 /** Unregisters an Action.71 * \param *action pointer to Action.72 */73 47 void ActionRegistry::unregisterAction(Action* action){ 74 //cout << "Unregistering action with name " << action->getName() << "." << endl;75 48 actionMap.erase(action->getName()); 76 49 } 77 50 78 /** Returns an iterator pointing to the start of the map of Action's.79 * \return begin iterator80 */81 51 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 82 52 { … … 84 54 } 85 55 86 /** Returns an iterator pointing to the end of the map of Action's.87 * \return end iterator88 */89 56 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 90 57 { … … 92 59 } 93 60 94 /** Returns a const iterator pointing to the start of the map of Action's.95 * \return constant begin iterator96 */97 std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const98 {99 return actionMap.begin();100 }101 102 /** Returns a const iterator pointing to the end of the map of Action's.103 * \return constant end iterator104 */105 std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const106 {107 return actionMap.end();108 }109 110 /** Prints the contents of the ActionRegistry \a &m to \a &ost.111 * \param &ost output stream112 * \param &m reference to ActionRegistry113 * \return reference to the above out stream for concatenation114 */115 ostream& operator<<(ostream& ost, const ActionRegistry& m)116 {117 ost << "ActionRegistry contains:" << endl;118 for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {119 ost << "\t" << iter->first << " with pointer " << iter->second << endl;120 }121 return ost;122 };123 124 125 126 61 CONSTRUCT_SINGLETON(ActionRegistry)
Note:
See TracChangeset
for help on using the changeset viewer.
