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


C++ Events类代码示例

本文整理汇总了C++中Events的典型用法代码示例。如果您正苦于以下问题:C++ Events类的具体用法?C++ Events怎么用?C++ Events使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Events类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: events

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

示例2: list_assembly

static void
list_assembly(const SqlDatabase::TransactionPtr &tx, int func_id)
{
    Events events;
    gather_events(tx, func_id);
    load_events(tx, func_id, events);

    SqlDatabase::StatementPtr stmt = tx->statement("select address, assembly from semantic_instructions where func_id = ?"
                                                   " order by position")->bind(0, func_id);
    for (SqlDatabase::Statement::iterator insn=stmt->begin(); insn!=stmt->end(); ++insn) {
        rose_addr_t addr = insn.get<rose_addr_t>(0);
        std::string assembly = insn.get<std::string>(1);
        Events::const_iterator ei=events.find(addr);

        // Assembly line prefix
        if (ei!=events.end() && ei->second.nexecuted>0) {
            std::cout <<std::setw(9) <<std::right <<ei->second.nexecuted <<"x ";
        } else {
            std::cout <<std::string(11, ' ');
        }

        // Assembly instruction
        std::cout <<"| " <<StringUtility::addrToString(addr) <<":  " <<assembly <<"\n";

        if (ei!=events.end())
            show_events(ei->second);
    }
}
开发者ID:matzke1,项目名称:rose-develop,代码行数:28,代码来源:90-list-function.C

示例3: Timer

void Client::init() {
    Debug::log("INIT");
    
    // INIT WINDOW
    WSFML *window = WSFML::instance();
    
    // CREATE CONTROL
    c = Control::instance();
    
    // CAMERA
    cam = Camera::instance();
    
    // TIME
    t = new Timer();
    
    hasStartEvent = false;

    window->getWindow()->setActive(false);
    
    sf::Thread thread_game(&Client::startGameLoop, this);
    thread_game.launch();
    
    Net *net = new Net();
    sf::Thread thread_net(&Net::startNet, net);
    thread_net.launch();
    
    while(hasStartEvent == false)
        sf::sleep(sf::milliseconds(1));
    
    printf("START\n");
    
    Events e;
    e.startListening(w->getPlayer());
}
开发者ID:pajon,项目名称:build-age,代码行数:34,代码来源:Client.cpp

示例4: main

int main(int, char**)
{
    Events<> e0; Events<int> e1; Events<bool, int> e2; Variable<int> v; Variable<int*> va;
    auto vf = constant([] (int x) { return x * 9; });
    auto vb = constant([] (int x) { return x > 9; });
    Events<Events<int>> ee;
    Variable<Variable<int>> vv;
    Events<void (*)()> ex;
    Variable<Events<>> ve;

    {
        Events<int> a(e1);
        Events<int> b = e1.mergedWith(a);
        Events<bool> c = e2.transformedBy([] (bool b, int n) { return b || n > 9; });
        Events<int> d = b.transformedBy(vf);
        Events<bool, int> e = e2.filteredBy([] (bool b, int) { return b; });
        //Events<bool, int> f = e.filteredBy(v.transformedBy([] (int n) { return n < 0; }));
        //Events<int> g = e1.filteredBy(vb);
        std::array<Events<int>, 4> h = e1.partitionedBy<4>([] (int n) { return n % 4; });
        Events<bool> i = e0.taggedWith(false);
        Events<bool, int> j = e1.taggedAtFrontWith(true);
        Events<int> k = e0.withSnapshotOf(v);
        Events<int, int> l = k.withSnapshotAtFrontOf(v);
        Events<int, bool, bool, bool> m = e2.positions<1, 0, 0, 0>();
        Events<std::tuple<bool, int>> n = e2.tupled();
        Events<bool, int> o = n.untupled();
        Events<int> p = ee.flattened();
        Variable<int> q = e1.lastValueStartingWith(0);
        Variable<std::array<int, 5>> r = e1.historyStartingWithDefaults<5>();
        Variable<std::vector<int>> s = e1.history(9);
        Variable<int> t = e2.count();
        ex.exec();
        Events<int> u = r.changes()[4];
        Events<int> w = r.changes()[v];
        Events<bool> x = vb.changes()(9);
        Events<bool> y = vb.changes()(v);
        Events<int> z = u * 9 - v;
    }

    {
        Variable<int> a(5);
        Variable<int> b(5, e1);
        Variable<int> c(b);
        Variable<bool> d = a.transformedBy([] (int n) { return n < 55; });
        Variable<bool> e = b.transformedBy(vb);
        Variable<int> f = vv.flattened();
        Variable<int> g = va[5];
        Variable<int> h = va[v];
        Variable<bool> i = vb(9);
        Variable<bool> j = vb(v);
        Variable<bool> k = (vf((a + b * c) << 9) < g) || i;
        Variable<std::tuple<bool, int, int>> l = tupled(d, b, a);
        Variable<int> m = sample([] () { return 99; }, e0);
        Events<> n = variableEvents(ve);
        Mutable<int> o;
        o /= 9;
    }
}
开发者ID:glaebhoerl,项目名称:cplusplus-frp,代码行数:58,代码来源:test.cpp

示例5: fillEvent

Events Database::fillEvent()
{
    Events e;
    this->query.first();
    this->record = this->query.record();
    e.setId(this->query.value(this->record.indexOf("id")).toUInt());
    e.setDescription(this->query.value(this->record.indexOf("name")).toString());
    return e;
}
开发者ID:gavaza,项目名称:pacca,代码行数:9,代码来源:database.cpp

示例6: deviceEventCallback

void Events::deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *context) {
	Events *e = reinterpret_cast<Events *>(context);
	if (e) {
		/** Please note!
		 * We are here in another thread than the main. Some measures to syncronize
		 * this must be taken!
		 **/
		e->deviceEvent(deviceId, method, data);
	}
}
开发者ID:Balex93,项目名称:telldus,代码行数:10,代码来源:main.cpp

示例7: gather_instructions

// Create the tmp_insns table to hold all the instructions for the function-to-be-listed and all the instructions of all
// the functions that are mentioned in events.
static void
gather_instructions(const SqlDatabase::TransactionPtr tx, int func_id, const Events &events)
{
    std::set<std::string> func_ids;
    func_ids.insert(StringUtility::numberToString(func_id));
    for (Events::const_iterator ei=events.begin(); ei!=events.end(); ++ei)
        func_ids.insert(StringUtility::numberToString(ei->second.func_id));
    std::string sql = "create temporary table tmp_insns as"
                      " select * from semantic_instructions"
                      " where func_id in ("+StringUtility::join_range(", ", func_ids.begin(), func_ids.end())+")";
    tx->execute(sql);
}
开发者ID:matzke1,项目名称:rose-develop,代码行数:14,代码来源:90-list-function.C

示例8: takeEvents

bool EventQueue::takeEvents(Events& events)
{
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
    if (!_eventQueue.empty())
    {
        events.splice(events.end(), _eventQueue);
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:13,代码来源:EventQueue.cpp

示例9: copyEvents

bool EventQueue::copyEvents(Events& events) const
{
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
    if (!_eventQueue.empty())
    {
        events.insert(events.end(),_eventQueue.begin(),_eventQueue.end());
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:13,代码来源:EventQueue.cpp

示例10: 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

示例11: lock

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

示例12: tox4j_self_connection_status_cb

static void
tox4j_self_connection_status_cb (Tox *tox, TOX_CONNECTION connection_status, Events &events)
{
  unused (tox);
  auto msg = events.add_self_connection_status ();
  set_connection_status (msg, connection_status);
}
开发者ID:gattschardo,项目名称:tox4j,代码行数:7,代码来源:lifecycle.cpp

示例13: tox4j_friend_read_receipt_cb

static void
tox4j_friend_read_receipt_cb (Tox *tox, uint32_t friend_number, uint32_t message_id, Events &events)
{
  unused (tox);
  auto msg = events.add_friend_read_receipt ();
  msg->set_friend_number (friend_number);
  msg->set_message_id (message_id);
}
开发者ID:gattschardo,项目名称:tox4j,代码行数:8,代码来源:lifecycle.cpp

示例14: main

Q_DECL_EXPORT int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    app.setOrganizationName("cuteTube Events");
    app.setApplicationName("cuteTube Events");
    app.setApplicationVersion("0.1.0");
    
    QSslConfiguration config = QSslConfiguration::defaultConfiguration();
    config.setProtocol(QSsl::TlsV1);
    QSslConfiguration::setDefaultConfiguration(config);
    
    Events events;
    events.getEvents();
    
    QObject::connect(&events, SIGNAL(finished()), &app, SLOT(quit()));
    
    return app.exec();
}
开发者ID:marxoft,项目名称:cutetubeevents,代码行数:17,代码来源:main.cpp

示例15: lock

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


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