Пример #1
0
void CmdManager::registerCommand(const Cmd& cmd)
{
	QMap<QString, Cmd>::iterator it = m_CommandMap.find(cmd.name());

	if (it == m_CommandMap.end()) {
		m_Commands.push_back(cmd);

		m_CommandMap.insert(cmd.name(), cmd);
	}
}
Пример #2
0
void CmdManager::unregisterCommand(const Cmd& cmd)
{
	QMap<QString, Cmd>::iterator it = m_CommandMap.find(cmd.name());

	if (it != m_CommandMap.end()) {
		std::vector<Cmd>::iterator cmdIt = m_Commands.begin();

		while (cmdIt != m_Commands.end()) {
			if (cmd.name() == (*cmdIt).name()) {
				m_Commands.erase(cmdIt);
				break;
			}
			++cmdIt;
		}
		m_CommandMap.erase(it);
	}
}