/* * ActionRegistry.cpp * * Created on: Jan 7, 2010 * Author: crueger */ #include "Actions/ActionRegistry.hpp" #include "Actions/Action.hpp" #include "Patterns/Singleton_impl.hpp" #include #include #include using namespace std; ActionRegistry::ActionRegistry() { } ActionRegistry::~ActionRegistry() { map::iterator iter; for(iter=actionMap.begin();iter!=actionMap.end();++iter) { delete iter->second; } actionMap.clear(); } Action* ActionRegistry::getActionByName(const std::string name){ map::iterator iter; iter = actionMap.find(name); assert(iter!=actionMap.end() && "Query for an action not stored in registry"); return iter->second; } void ActionRegistry::registerAction(Action* action){ pair::iterator,bool> ret; ret = actionMap.insert(pair(action->getName(),action)); assert(ret.second && "Two actions with the same name added to registry"); } CONSTRUCT_SINGLETON(ActionRegistry)