/* * ActionRegistry.cpp * * Created on: Jan 7, 2010 * Author: crueger */ #include "Actions/ActionRegistry.hpp" #include "Actions/Action.hpp" #include #include #include using namespace std; ActionRegistry *ActionRegistry::theInstance=0; ActionRegistry::ActionRegistry() { } ActionRegistry::~ActionRegistry() { map::iterator iter; for(iter=actionMap.begin();iter!=actionMap.end();iter++) { delete iter->second; actionMap.erase(iter); } } 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"); } // singleton stuff ActionRegistry* ActionRegistry::getRegistry(){ if(!theInstance){ theInstance = new ActionRegistry(); } return theInstance; } void ActionRegistry::purgeRegistry(){ if(theInstance){ delete theInstance; theInstance = 0; } }