当前位置: 首页>>代码示例>>C++>>正文


C++ Events::push_back方法代码示例

本文整理汇总了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;
    }
}
开发者ID:carlsonp,项目名称:osg,代码行数:27,代码来源:EventQueue.cpp

示例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));
    }
  }
}
开发者ID:RomanUlan,项目名称:ThreadPool,代码行数:26,代码来源:Epoll.cpp

示例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;
	}
}
开发者ID:artpaul,项目名称:acto,代码行数:33,代码来源:services.cpp

示例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;
}
开发者ID:r0mai,项目名称:jtt-competition-rank-visualiser,代码行数:34,代码来源:main.cpp

示例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;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:14,代码来源:EventLog.cpp

示例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);
    }
开发者ID:psde,项目名称:gosu,代码行数:16,代码来源:InputWin.cpp

示例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;
    }
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:46,代码来源:EventQueue.cpp

示例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)
//.........这里部分代码省略.........
开发者ID:psde,项目名称:gosu,代码行数:101,代码来源:InputWin.cpp

示例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:
                {
//.........这里部分代码省略.........
开发者ID:DerekMaffett,项目名称:robotank-showdown,代码行数:101,代码来源:InputWin.cpp


注:本文中的Events::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。