本文整理汇总了C++中EventSP::GetBroadcaster方法的典型用法代码示例。如果您正苦于以下问题:C++ EventSP::GetBroadcaster方法的具体用法?C++ EventSP::GetBroadcaster怎么用?C++ EventSP::GetBroadcaster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSP
的用法示例。
在下文中一共展示了EventSP::GetBroadcaster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
bool operator() (const EventSP &event_sp) const
{
if (m_broadcaster && !event_sp->BroadcasterIs(m_broadcaster))
return false;
if (m_broadcaster_names)
{
bool found_source = false;
const ConstString &event_broadcaster_name = event_sp->GetBroadcaster()->GetBroadcasterName();
for (uint32_t i=0; i<m_num_broadcaster_names; ++i)
{
if (m_broadcaster_names[i] == event_broadcaster_name)
{
found_source = true;
break;
}
}
if (!found_source)
return false;
}
if (m_event_type_mask == 0 || m_event_type_mask & event_sp->GetType())
return true;
return false;
}
示例2: HandleBroadcastEvent
size_t Listener::HandleBroadcastEvent(EventSP &event_sp) {
size_t num_handled = 0;
std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
Broadcaster *broadcaster = event_sp->GetBroadcaster();
if (!broadcaster)
return 0;
broadcaster_collection::iterator pos;
broadcaster_collection::iterator end = m_broadcasters.end();
Broadcaster::BroadcasterImplSP broadcaster_impl_sp(
broadcaster->GetBroadcasterImpl());
for (pos = m_broadcasters.find(broadcaster_impl_sp);
pos != end && pos->first.lock() == broadcaster_impl_sp; ++pos) {
BroadcasterInfo info = pos->second;
if (event_sp->GetType() & info.event_mask) {
if (info.callback != nullptr) {
info.callback(event_sp, info.callback_user_data);
++num_handled;
}
}
}
return num_handled;
}
示例3: locker
size_t
Listener::HandleBroadcastEvent (EventSP &event_sp)
{
size_t num_handled = 0;
Mutex::Locker locker(m_broadcasters_mutex);
Broadcaster *broadcaster = event_sp->GetBroadcaster();
broadcaster_collection::iterator pos;
broadcaster_collection::iterator end = m_broadcasters.end();
for (pos = m_broadcasters.find (broadcaster);
pos != end && pos->first == broadcaster;
++pos)
{
BroadcasterInfo info = pos->second;
if (event_sp->GetType () & info.event_mask)
{
if (info.callback != NULL)
{
info.callback (event_sp, info.callback_user_data);
++num_handled;
}
}
}
return num_handled;
}