本文整理汇总了C++中EventHandler::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::getId方法的具体用法?C++ EventHandler::getId怎么用?C++ EventHandler::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::getId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeHandler
// synchronized
void InitiationDispatcher::removeHandler(const EventHandler & handler,
const EventType & type)
{
BOOST_LOG_TRIVIAL(trace) << "InitiationDispatcher entering removeHandler.";
lock_guard<mutex> grd_lock(m_mutex);
string id = handler.getId();
BOOST_LOG_TRIVIAL(trace) << "Searching event handler w/ID ["
<< id
<< "]";
auto type_handler = m_handlers.find(id);
if(type_handler != m_handlers.end())
{
// found handler
if (type_handler->second.type == type)
{
BOOST_LOG_TRIVIAL(info) << "Removing event handler w/ID ["
<< id + "] and type ["
<< EventTypeMap[type]
<< "]";
m_handlers.erase(id);
}
}
}
示例2: registerHandler
// synchronized
void InitiationDispatcher::registerHandler(
const EventHandler & handler,
const EventType & type)
{
BOOST_LOG_TRIVIAL(info) <<
"InitiationDispatcher entering registerHandler.";
lock_guard<mutex> grd_lock(m_mutex);
if(m_is_closed)
{
throw new runtime_error(
"The initiation dispatcher is closed.");
}
string id = handler.getId();
BOOST_LOG_TRIVIAL(info) <<
"Registering event handler w/ID [" +
id + "] and type [" +
EventTypeMap[type] + "]";
if (m_handlers.find(id))
{
throw invalid_argument ("Event handler with ID [" +
id + "] has already been registered.");
}
EventTypeHandler type_handler;
type_handler.type = type;
type_handler.handler = handler;
m_handlers.insert(
pair<string,EventTypeHandler>(id, type_handler));
}