本文整理汇总了C++中Events::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Events::push_back方法的具体用法?C++ Events::push_back怎么用?C++ Events::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Events
的用法示例。
在下文中一共展示了Events::push_back方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: takeEvents
bool EventQueue::takeEvents(Events& events, double cutOffTime)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
if (!_eventQueue.empty())
{
bool eventsTaken = false;
Events::iterator itr = _eventQueue.begin();
for(;
itr != _eventQueue.end() && ((*itr)->getTime() <= cutOffTime);
++itr)
{
events.push_back(*itr);
eventsTaken = true;
}
if (eventsTaken)
{
_eventQueue.erase(_eventQueue.begin(), itr);
}
return eventsTaken;
}
else
{
return false;
}
}
示例2: wait
void Epoll::wait(Events& p_events) const
{
boost::scoped_array<epoll_event> events(new epoll_event[m_size]);
::memset(events.get(), 0, m_size * sizeof (epoll_event));
int eventsLen = ::epoll_wait(m_epollFd, events.get(), m_size, -1);
if (eventsLen < 0)
{
throw std::runtime_error("Epoll wait failed");
}
for (int i = 0; i < eventsLen; ++i)
{
if (events[i].data.fd == m_selfStopPipes[0])
{
p_events.clear();
break;
}
else
{
EventTypes ets;
nativeEvents(events[i].events, ets);
p_events.push_back(Event(ets, events[i].data.fd));
}
}
}
示例3: do_setup
//-------------------------------------------------------------------------------------------------
void TimerActor::do_setup (acto::actor_ref& sender, const TimerActor::msg_setup& msg) {
event_t* const p_event = new event_t( actor_ref() );
// -
p_event->actor = msg.actor;
p_event->once = msg.once;
p_event->time = msg.time;
p_event->owner = self;
// -
// core::set_notify( 0, acto::dereference(actor), MakeDelegate(this, &timer_t::do_delete) );
// Установить системный таймер
if ( 0 != ::CreateTimerQueueTimer( &p_event->timer,
// Очередь таймеров
m_timers,
// -
&TimerActor::TimerProc,
// Параметр для процедуры
p_event,
// Период первого вызова
msg.time,
// Повторы
(msg.once ? 0 : msg.time),
// Флаги
0 ) )
{
// -
m_events.push_back( p_event );
}
else {
// Ошибка. Таймер не был созда.
delete p_event;
}
}
示例4: main
int main() {
std::string line;
Events events;
while (std::getline(std::cin, line)) {
std::vector<std::string> elements;
boost::split(elements, line, boost::is_any_of("/"));
if (elements.size() != 4) {
std::cerr << "Warning: elements.size() != 4" << std::endl;
continue;
}
Event e;
e.player = elements[0];
e.map = elements[1];
e.lapTime = parseLapTime(elements[2]);
e.date = parseDate(elements[3]);
events.push_back(e);
}
std::cout << "Number of events: " << events.size() << std::endl;
std::sort(events.begin(), events.end());
std::cout << "Last event: " << events.back() << std::endl;
Ranking ranking = getRankings(events, boost::posix_time::time_from_string("2014-01-03 22:00:00.000"));
for ( unsigned i = 0; i < 20 && i < ranking.size(); ++i ) {
std::cout << i+1 << ".: " << ranking[i].getPlayer() << ", Time: " << ranking[i].getTotalLapTime() << std::endl;
}
std::cout << "Current leader = " << ranking[0].getTotalLapTime() << std::endl;
}
示例5: Get
Events CEventLog::Get(EventLevel level, bool includeHigherLevels /* = false */) const
{
Events events;
CSingleLock lock(m_critical);
for (const auto& eventPtr : m_events)
{
if (eventPtr->GetLevel() == level ||
(includeHigherLevels && eventPtr->GetLevel() > level))
events.push_back(eventPtr);
}
return events;
}
示例6: forceButton
// For devices with buffered data.
void forceButton(unsigned id, bool down, bool collectEvent)
{
buttons.at(id) = down;
if (!collectEvent)
return;
EventInfo newEvent;
if (down)
newEvent.action = EventInfo::buttonDown;
else
newEvent.action = EventInfo::buttonUp;
newEvent.id = id;
events.push_back(newEvent);
}
示例7: takeEvents
bool EventQueue::takeEvents(Events& events, double cutOffTime)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
if (!_eventQueue.empty())
{
// find last event if queue that came in before the cuttof.
Events::reverse_iterator ritr = _eventQueue.rbegin();
for(; ritr != _eventQueue.rend() && ((*ritr)->getTime() > cutOffTime); ++ritr) {}
if (ritr==_eventQueue.rend()) return false;
for(Events::iterator itr = _eventQueue.begin();
itr != ritr.base();
++itr)
{
events.push_back(*itr);
}
// make sure that the events are in ascending time order, and any out of out events
// have their time reset to the next valid time after them in the events list.
double previousTime = cutOffTime;
for(Events::reverse_iterator itr = events.rbegin();
itr != events.rend();
++itr)
{
if ((*itr)->getTime() > previousTime)
{
OSG_INFO<<"Reset event time from "<<(*itr)->getTime()<<" to "<<previousTime<<std::endl;
(*itr)->setTime(previousTime);
}
else
{
previousTime = (*itr)->getTime();
}
}
// remove the events we are taking from the original event queue.
_eventQueue.erase(_eventQueue.begin(), ritr.base());
return true;
}
else
{
return false;
}
}
示例8: updateButtons
void updateButtons(bool collectEvents)
{
DIDEVICEOBJECTDATA data[inputBufferSize];
DWORD inOut;
HRESULT hr;
RECT rect;
::GetClientRect(window, &rect);
bool ignoreClicks = mouseX < 0 || mouseX > rect.right || mouseY < 0 || mouseY > rect.bottom;
inOut = inputBufferSize;
hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0);
switch(hr)
{
case DI_OK:
case DI_BUFFEROVERFLOW:
{
// Everything's ok: Update buttons and fire events.
for (unsigned i = 0; i < inOut; ++i)
{
bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks;
switch (data[i].dwOfs)
{
case DIMOFS_BUTTON0:
{
unsigned id = swapMouse ? msRight : msLeft;
setButton(id, down, collectEvents);
break;
}
case DIMOFS_BUTTON1:
{
unsigned id = swapMouse ? msLeft : msRight;
setButton(id, down, collectEvents);
break;
}
case DIMOFS_BUTTON2:
{
setButton(msMiddle, down, collectEvents);
break;
}
case DIMOFS_Z:
{
if (!collectEvents || data[i].dwData == 0)
break;
EventInfo event;
event.action = EventInfo::buttonDown;
if (int(data[i].dwData) < 0)
event.id = msWheelDown;
else
event.id = msWheelUp;
events.push_back(event);
event.action = EventInfo::buttonUp;
events.push_back(event);
break;
}
}
}
break;
}
case DIERR_NOTACQUIRED:
case DIERR_INPUTLOST:
{
// Cannot fetch new events: Release all buttons.
for (unsigned id = msRangeBegin; id < msRangeEnd; ++id)
setButton(id, false, collectEvents);
mouse->Acquire();
break;
}
}
keyboard:
inOut = inputBufferSize;
hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0);
switch (hr)
{
case DI_OK:
case DI_BUFFEROVERFLOW:
{
for (unsigned i = 0; i < inOut; ++i)
forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents);
break;
}
case DIERR_NOTACQUIRED:
case DIERR_INPUTLOST:
{
for (unsigned id = kbRangeBegin; id < kbRangeEnd; ++id)
setButton(id, false, collectEvents);
keyboard->Acquire();
break;
}
}
boost::array<bool, gpNum> gpBuffer;
gpBuffer.assign(false);
for (unsigned gp = 0; gp < gamepads.size(); ++gp)
//.........这里部分代码省略.........
示例9: updateButtons
void updateButtons(bool collectEvents)
{
DIDEVICEOBJECTDATA data[inputBufferSize];
DWORD inOut;
HRESULT hr;
RECT rect;
::GetClientRect(window, &rect);
bool ignoreClicks = mouseX < 0 || mouseX > rect.right || mouseY < 0 || mouseY > rect.bottom;
inOut = inputBufferSize;
hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0);
switch(hr)
{
case DI_OK:
case DI_BUFFEROVERFLOW:
{
// Everything's ok: Update buttons and fire events.
for (unsigned i = 0; i < inOut; ++i)
{
bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks;
// No switch statement here because it breaks compilation with MinGW.
if (data[i].dwOfs == DIMOFS_BUTTON0)
{
unsigned id = swapMouse ? msRight : msLeft;
setButton(id, down, collectEvents);
}
else if (data[i].dwOfs == DIMOFS_BUTTON1)
{
unsigned id = swapMouse ? msLeft : msRight;
setButton(id, down, collectEvents);
}
else if (data[i].dwOfs == DIMOFS_BUTTON2)
{
setButton(msMiddle, down, collectEvents);
}
else if (data[i].dwOfs == DIMOFS_Z &&
collectEvents && data[i].dwData)
{
EventInfo event;
event.action = EventInfo::buttonDown;
if (int(data[i].dwData) < 0)
event.id = msWheelDown;
else
event.id = msWheelUp;
events.push_back(event);
event.action = EventInfo::buttonUp;
events.push_back(event);
}
}
break;
}
case DIERR_NOTACQUIRED:
case DIERR_INPUTLOST:
{
// Cannot fetch new events: Release all buttons.
for (unsigned id = msRangeBegin; id <= msRangeEnd; ++id)
setButton(id, false, collectEvents);
mouse->Acquire();
break;
}
}
inOut = inputBufferSize;
hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0);
switch (hr)
{
case DI_OK:
case DI_BUFFEROVERFLOW:
{
for (unsigned i = 0; i < inOut; ++i)
forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents);
break;
}
case DIERR_NOTACQUIRED:
case DIERR_INPUTLOST:
{
for (unsigned id = kbRangeBegin; id <= kbRangeEnd; ++id)
setButton(id, false, collectEvents);
keyboard->Acquire();
break;
}
}
std::tr1::array<bool, gpNum> gpBuffer = { false };
for (unsigned gp = 0; gp < gamepads.size() && gp < numGamepads; ++gp)
{
gamepads[gp]->Poll();
int rangeOffset = (gp + 1) * gpNumPerGamepad - gpRangeBegin;
DIJOYSTATE joy;
hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy);
switch (hr)
{
case DI_OK:
{
//.........这里部分代码省略.........