MgCommand* MgCmdManagerImpl::findCommand(const char* name) { CMDS::iterator it = _cmds.find(name); if (it == _cmds.end() && *name) { MgCommand* cmd = NULL; Factories::iterator itf = _factories.find(name); if (itf != _factories.end() && itf->second) { cmd = (itf->second)(); } if (!cmd && strcmp(name, "select") == 0) { cmd = MgCmdSelect::Create(); } if (cmd) { _cmds[name] = cmd; it = _cmds.find(name); } } return it != _cmds.end() ? it->second : NULL; }
void add_factory(const char* name) { assert(factories.find(name) == factories.end()); factories[name] = std::unique_ptr<AbstractObjectFactory>(new ConcreteObjectFactory<C>()); }