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


C++ Event类代码示例

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


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

示例1: compressLoopLCS

iteration_t* Trace::compressLoopLCS(iteration_t* iteration){
  Event *iter;
  int max, count, iteration_length;
  iteration_t *current, *rtn;
  vector<matching_pair_t *> *pairs = NULL;
  vector<iteration_t *> iterations;
  vector<iteration_t *>::iterator iteration_it;

  /* delete the current iteration from pendingIterations so that it won't be
   * evaluated repeatedly */
  pendingIterations.deleteIteration(iteration);

  /* check if there is pending iteration inside the target iteration */
  for(iter = iteration->target_head; iter != iteration->target_tail->next && iter != NULL; iter = iter->next){
    if(iter->checkLoc(LEADER)){
      /* loops are either completely disjoint or perfectly embedded: if there is
       * a LEADER event (merge_head) in an iteration, the corresponding merge_tail,
       * target_head, target_tail must also be in the same iteration. Therefore, when
       * we merge target_head ... target_tail into the previous iteration and remove
       * them, we only have to handle the case where target_tail is also the last event
       * of a larger iteration that directly or indirectly contains the two iterations
       * merge_head ... merge_tail target_head ... target_tail.
       */
      iterations = pendingIterations.getIterationsByMergeHead(iter);
      max = INT_MIN;
      current = NULL;
      for(iteration_it = iterations.begin(); iteration_it != iterations.end(); ++iteration_it){
        if((*iteration_it)->merge_length > max){
          current = *iteration_it;
          max = (*iteration_it)->merge_length;
        }
      }
      if(current){
        if(iteration->target_tail == current->target_tail){
          rtn = compressLoopLCS(current);
          iteration->target_tail = rtn->merge_tail;
        } else {
          rtn = compressLoopLCS(current);
        }
        if(rtn)
          delete rtn;
      }
    }
  }

  /* check if there is pending iteration inside the merge iteration */
  for(iter = iteration->merge_head; iter != iteration->merge_tail->next && iter != NULL; iter = iter->next){
    if(iter->checkLoc(LEADER)){
      iterations = pendingIterations.getIterationsByMergeHead(iter);
      max = INT_MIN;
      current = NULL;
      for(iteration_it = iterations.begin(); iteration_it != iterations.end(); ++iteration_it){
        if((*iteration_it)->merge_length > max){
          current = *iteration_it;
          max = (*iteration_it)->merge_length;
        }
      }
      if(current){
        if(iteration->merge_tail == current->target_tail){
          rtn = compressLoopLCS(current);
          iteration->merge_tail = rtn->merge_tail;
        } else {
          rtn = compressLoopLCS(current);
        }
        if(rtn)
          delete rtn;
      }
    }
  }

  for(iter = iteration->target_head, count = 1; iter != iteration->target_tail; iter = iter->next, count++);
  iteration->target_length = count;
  for(iter = iteration->merge_head, count = 1; iter != iteration->merge_tail; iter = iter->next, count++);
  iteration->merge_length = count;

  pairs = matchLoopLCS(iteration->merge_head, iteration->merge_tail, iteration->merge_length,
      iteration->target_head, iteration->target_tail, iteration->target_length );
  if(!pairs){
    assert(0);
  } else {
    iteration_length = updateLoopLCS(iteration->merge_head, iteration->merge_tail,
        iteration->merge_length, iteration->target_head, iteration->target_tail, pairs);
    mergeLoopEvents(iteration->merge_head, iteration->merge_tail,
        iteration->target_head, iteration->target_tail);
    updateLoopInfo(iteration->merge_head, iteration->merge_tail, iteration->target_head,
        iteration->target_tail, iteration_length);
    deleteIteration(iteration->target_head, iteration->target_tail);
  }

  for(unsigned i=0; i<pairs->size(); i++)
    delete pairs->at(i);
  delete pairs;

  iteration->target_head = NULL;
  iteration->target_tail = NULL;
  iteration->target_length = 0;
  iteration->merge_length = iteration_length;
  return iteration;
}
开发者ID:anshulgupta0803,项目名称:ScalaTrace-TI,代码行数:99,代码来源:Trace.C

示例2: change_request

void probProcessor::change_request(Event& event){

  cafe::Config config(name());
  
  
  
  if (!MCREQID) throw runtime_error("ERROR:  processor MCReqID is not initialized.") ;
  
  // verify if request id is stay the same. In that case do nothing.
  
  if ( MCREQID->reqid() == _reqid ) return ;
  _reqid = MCREQID->reqid() ;
  
  // verify data epochs associated to this MC
  const vector<string>* epochs =  MCREQID->current_data_epochs();

  // Actually we could do better than just checking if the reqid changed,
  // if the current_data_epochs did not change we can also stop.
  // This is a little work, but much faster than rereading all trigger map
  bool same_epochs=true;
  if(_previous_epochs.size() == epochs->size()){
    for(int i=0; i<epochs->size(); i++){
      if(_previous_epochs[i] != epochs->at(i)){
	same_epochs=false;
	break;
      }
    }
  }else{
    same_epochs=false;
  }
  if(same_epochs) return;
  else{
    _previous_epochs.clear();
    for(int i=0; i<epochs->size(); i++) _previous_epochs.push_back(epochs->at(i));
  }


  //Get new maps of trigger versions and lumis (provided by cafTriggerEfficiency)
  _mapVersionLumi.clear();
  _mapVersionLumi1.clear();
  _mapVersionLumi2.clear();
  event.get("passedVersionLumi", _mapVersionLumi);
  event.get("passedVersionLumi1", _mapVersionLumi1);
  event.get("passedVersionLumi2", _mapVersionLumi2);


  //// This is a quick solution, but really _trigger_version and _trigger_lumi should be
  //// completely removed and only _mapVersionLumi should be used
  _trigger_version.clear();
  _trigger_lumi.clear();
  for(map<string, float>::iterator it = _mapVersionLumi.begin(); it != _mapVersionLumi.end(); ++it) {
    _trigger_version.push_back((*it).first);
    _trigger_lumi.push_back((*it).second);
  }


  if(_debug){ 
    cout<<"trigger version now has "<< _trigger_version.size()<<" entries. "<<endl; 
    cout<<"triglists: ";
    for (int i=0; i < _trigger_version.size(); i++) cout<<_trigger_version[i]<<" ";
    cout<<endl;
  }

  //// Update the trigger map (must be defined in children classes)
  // change_triggermap();
  // Moved to the beginning of defineEffInfo() define in child classes
  
  map< string, EffInfo > effInfo ;
  
  defineEffInfo(effInfo) ;
  
  //Set up the sigma variables with the effInfo
  sigmaSet(effInfo);
  
  for (map< string, EffInfo >::iterator it = effInfo.begin();
       it != effInfo.end(); it++) {
    
    //      cout << "Adding " << it->first << " to the map." << endl;
    //With our objectProb mapping, we fill it with the constructed objects
    string path = DeterminePath(it->first);
      
//       cout << endl << endl;
//       cout << "Prob:" << endl;
//       cout << "  " << it->first << endl;
//       cout << endl;
    
    _objectProb[it->first] = objectProbabilities(it->second, path, 
						 _ignoreOverflow, _ignoreUnderflow);
    
  }
  
}
开发者ID:hengne,项目名称:d0wmass,代码行数:92,代码来源:probProcessor.cpp

示例3: parseVObject

static Event parseVObject( VObject *obj )
{
    Event e;

    bool haveAlarm = FALSE;
    bool haveStart = FALSE;
    bool haveEnd = FALSE;
    QDateTime alarmTime;
    Event::SoundTypeChoice soundType = Event::Silent;

    VObjectIterator it;
    initPropIterator( &it, obj );
    while( moreIteration( &it ) ) {
        VObject *o = nextVObject( &it );
        QCString name = vObjectName( o );
        QCString value = vObjectStringZValue( o );
        if ( name == VCDTstartProp ) {
            e.setStart( TimeConversion::fromISO8601( value ) );
            haveStart = TRUE;
        }
        else if ( name == VCDTendProp ) {
            e.setEnd( TimeConversion::fromISO8601( value ) );
            haveEnd = TRUE;
        }
        else if ( name == "X-Qtopia-NOTES" ) {
            e.setNotes( value );
        }
        else if ( name == VCDescriptionProp ) {
            e.setDescription( value );
        }
        else if ( name == VCLocationProp ) {
            e.setLocation( value );
        }
        else if ( name == VCAudioContentProp ) {
            haveAlarm = TRUE;
            VObjectIterator nit;
            initPropIterator( &nit, o );
            while( moreIteration( &nit ) ) {
                VObject *o = nextVObject( &nit );
                QCString name = vObjectName( o );
                QCString value = vObjectStringZValue( o );
                if ( name == VCRunTimeProp )
                    alarmTime = TimeConversion::fromISO8601( value );
                else if ( name == VCAudioContentProp ) {
                    if ( value == "silent" )
                        soundType = Event::Silent;
                    else
                        soundType = Event::Loud;
                }
            }
        }
        else if ( name == "X-Qtopia-TIMEZONE") {
            e.setTimeZone( value );
        }
        else if ( name == "X-Qtopia-AllDay" ) {
            e.setType( Event::AllDay );
        }
#if 0
        else {
            printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
            VObjectIterator nit;
            initPropIterator( &nit, o );
            while( moreIteration( &nit ) ) {
                VObject *o = nextVObject( &nit );
                QCString name = vObjectName( o );
                QString value = vObjectStringZValue( o );
                printf(" subprop: %s = %s\n", name.data(), value.latin1() );
            }
        }
#endif
    }

    if ( !haveStart && !haveEnd )
        e.setStart( QDateTime::currentDateTime() );

    if ( !haveEnd ) {
        e.setType( Event::AllDay );
        e.setEnd( e.start() );
    }

    if ( haveAlarm ) {
        int minutes = alarmTime.secsTo( e.start() ) / 60;
        e.setAlarm( TRUE, minutes, soundType );
    }
    return e;
}
开发者ID:opieproject,项目名称:opie,代码行数:86,代码来源:event.cpp

示例4:

void
ClientProxy1_6::handleClipboardSendingEvent(const Event& event, void*)
{
	ClipboardChunk::send(getStream(), event.getData());
}
开发者ID:sbiglia,项目名称:synergy,代码行数:5,代码来源:ClientProxy1_6.cpp

示例5: MNote

 MNote(const Event& _mc) : mc(_mc) {
       for (int i = 0; i < mc.notes().size(); ++i)
             ties.append(0);
       }
开发者ID:,项目名称:,代码行数:4,代码来源:

示例6: main


//.........这里部分代码省略.........
			Argument += 1;
			continue;
		}

		if ( strcmp( "-d", argv[Argument]) == 0 )
		{
			if ( Debug )
			{
				fprintf( stderr, "Warning: debug mode already set\n" );
			}
			Debug = true;
			continue;
		}

		sprintf( Message, "invalid option in parameter %d ('%s')", Argument+1, argv[Argument] );
		Usage( (const char *)Message );
	}

#ifdef _DEBUG
		// MsgSocket::Debug = MsgSocket::DBG_LINKSYNC;
#endif

	// Ok, it seems that parameters looks ok...
	// start registering service
	if ( Debug ) { printf("Launching service '%s' ", ServiceName.GetStr() ); }

	Service * pServ = ServiceFactory.Create( ServiceName );
	if ( Debug ) { printf("with ServiceId %s\n", pServ->GetPeerIdAsString().GetStr() ); }

	// Check argument before launching any registering process
	for( Argument = 2; Argument < argc; Argument++ )
	{
		if ( strcmp( "-o", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnOutput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-i", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnInput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-io", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnInOutput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-v", argv[Argument]) == 0 )
		{
			if ( Debug ) { printf( "Adding variable '%s' ('%s') with value '%s'...", argv[Argument+1], argv[Argument+2], argv[Argument+3] ); }

			if ( pServ->AddVariable( argv[Argument+1], SimpleString::EmptyString, argv[Argument+2], ReadWriteAccess ) == true )
			{
				pServ->SetVariableValue( argv[Argument+1], argv[Argument+3] );
				if ( Debug ) { printf( "done.\n" ); }
			}
			else
			{
				if ( Debug ) { printf( "failed.\n" ); }
			}

			Argument += 3;
			continue;
		}

		if ( strcmp( "-ct", argv[Argument]) == 0 )
		{
			// Already processed
			Argument += 1;
			 continue;
		}

		if ( strcmp( "-d", argv[Argument]) == 0 )
		{
			// Debug option already processed int the validity checking mode
			 continue;
		}

		sprintf( Message, "invalid option in parameter %d ('%s')", Argument+1, argv[Argument] );
		Usage( (const char *)Message );
	}

	pServ->Start();

	printf( "Waiting...\n" );
	// Lock Mylself
	Event ForEver;
	ForEver.Wait();

	return 0;
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:101,代码来源:BipService.cpp

示例7: SEISCOMP_DEBUG


//.........这里部分代码省略.........
	if ( stationMagnitude != NULL ) {
		// If the object has been added already to the parent locally
		// just remove it by pointer
		if ( object == parent() )
			return stationMagnitude->remove(this);
		// The object has not been added locally so it must be looked up
		else {
			Comment* child = stationMagnitude->comment(index());
			if ( child != NULL )
				return stationMagnitude->remove(child);
			else {
				SEISCOMP_DEBUG("Comment::detachFrom(StationMagnitude): comment has not been found");
				return false;
			}
		}
	}
	Pick* pick = Pick::Cast(object);
	if ( pick != NULL ) {
		// If the object has been added already to the parent locally
		// just remove it by pointer
		if ( object == parent() )
			return pick->remove(this);
		// The object has not been added locally so it must be looked up
		else {
			Comment* child = pick->comment(index());
			if ( child != NULL )
				return pick->remove(child);
			else {
				SEISCOMP_DEBUG("Comment::detachFrom(Pick): comment has not been found");
				return false;
			}
		}
	}
	Event* event = Event::Cast(object);
	if ( event != NULL ) {
		// If the object has been added already to the parent locally
		// just remove it by pointer
		if ( object == parent() )
			return event->remove(this);
		// The object has not been added locally so it must be looked up
		else {
			Comment* child = event->comment(index());
			if ( child != NULL )
				return event->remove(child);
			else {
				SEISCOMP_DEBUG("Comment::detachFrom(Event): comment has not been found");
				return false;
			}
		}
	}
	Origin* origin = Origin::Cast(object);
	if ( origin != NULL ) {
		// If the object has been added already to the parent locally
		// just remove it by pointer
		if ( object == parent() )
			return origin->remove(this);
		// The object has not been added locally so it must be looked up
		else {
			Comment* child = origin->comment(index());
			if ( child != NULL )
				return origin->remove(child);
			else {
				SEISCOMP_DEBUG("Comment::detachFrom(Origin): comment has not been found");
				return false;
			}
		}
开发者ID:ovsm-dev,项目名称:seiscomp3,代码行数:67,代码来源:comment.cpp

示例8: getEventTarget

void
StreamFilter::filterEvent(const Event& event)
{
	m_events->dispatchEvent(Event(event.getType(),
						getEventTarget(), event.getData()));
}
开发者ID:neilmayhew,项目名称:synergy,代码行数:6,代码来源:StreamFilter.cpp

示例9:

void V8Event::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    Event* event = V8Event::toNative(info.Holder());
    event->setDefaultPrevented(!value->BooleanValue());
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:5,代码来源:V8EventCustom.cpp

示例10: if

/**
 * A particular event has been triggered.
 * Process all of this events components.
 *
 * @param The triggered event
 * @return Returns true if the event shall not be run again.
 */
bool EventManager::executeEvent(Event &ev) {
    if(&ev == NULL) return false;

    // skip executing events that are on cooldown
    if (ev.cooldown_ticks > 0) return false;

    // set cooldown
    ev.cooldown_ticks = ev.cooldown;

    Event_Component *ec;

    for (unsigned i = 0; i < ev.components.size(); ++i) {
        ec = &ev.components[i];

        if (ec->type == "set_status") {
            camp->setStatus(ec->s);
        }
        else if (ec->type == "unset_status") {
            camp->unsetStatus(ec->s);
        }
        else if (ec->type == "intermap") {

            if (fileExists(mods->locate(ec->s))) {
                mapr->teleportation = true;
                mapr->teleport_mapname = ec->s;
                mapr->teleport_destination.x = static_cast<float>(ec->x) + 0.5f;
                mapr->teleport_destination.y = static_cast<float>(ec->y) + 0.5f;
            }
            else {
                ev.keep_after_trigger = false;
                mapr->log_msg = msg->get("Unknown destination");
            }
        }
        else if (ec->type == "intramap") {
            mapr->teleportation = true;
            mapr->teleport_mapname = "";
            mapr->teleport_destination.x = static_cast<float>(ec->x) + 0.5f;
            mapr->teleport_destination.y = static_cast<float>(ec->y) + 0.5f;
        }
        else if (ec->type == "mapmod") {
            if (ec->s == "collision") {
                if (ec->x >= 0 && ec->x < mapr->w && ec->y >= 0 && ec->y < mapr->h) {
                    mapr->collider.colmap[ec->x][ec->y] = static_cast<unsigned short>(ec->z);
                    mapr->map_change = true;
                }
                else
                    logError("EventManager: Mapmod at position (%d, %d) is out of bounds 0-255.", ec->x, ec->y);
            }
            else {
                int index = distance(mapr->layernames.begin(), find(mapr->layernames.begin(), mapr->layernames.end(), ec->s));
                if (!mapr->isValidTile(ec->z))
                    logError("EventManager: Mapmod at position (%d, %d) contains invalid tile id (%d).", ec->x, ec->y, ec->z);
                else if (ec->x >= 0 && ec->x < mapr->w && ec->y >= 0 && ec->y < mapr->h)
                    mapr->layers[index][ec->x][ec->y] = static_cast<unsigned short>(ec->z);
                else
                    logError("EventManager: Mapmod at position (%d, %d) is out of bounds 0-255.", ec->x, ec->y);
            }
        }
        else if (ec->type == "soundfx") {
            FPoint pos(0,0);
            bool loop = false;

            if (ec->x != -1 && ec->y != -1) {
                if (ec->x != 0 && ec->y != 0) {
                    pos.x = static_cast<float>(ec->x) + 0.5f;
                    pos.y = static_cast<float>(ec->y) + 0.5f;
                }
            }
            else if (ev.location.x != 0 && ev.location.y != 0) {
                pos.x = static_cast<float>(ev.location.x) + 0.5f;
                pos.y = static_cast<float>(ev.location.y) + 0.5f;
            }

            if (ev.type == "on_load")
                loop = true;

            SoundManager::SoundID sid = snd->load(ec->s, "MapRenderer background soundfx");

            snd->play(sid, GLOBAL_VIRTUAL_CHANNEL, pos, loop);
            mapr->sids.push_back(sid);
        }
        else if (ec->type == "loot") {
            ec->x = ev.hotspot.x;
            ec->y = ev.hotspot.y;
            mapr->loot.push_back(*ec);
        }
        else if (ec->type == "msg") {
            mapr->log_msg = ec->s;
        }
        else if (ec->type == "shakycam") {
            mapr->shaky_cam_ticks = ec->x;
        }
        else if (ec->type == "remove_currency") {
//.........这里部分代码省略.........
开发者ID:SBasalaev,项目名称:flare-engine,代码行数:101,代码来源:EventManager.cpp

示例11: HandleOpened

void ElevatorLogic::HandleOpened(Environment &env, const Event &e) {

	Elevator *ele = static_cast<Elevator*>(e.GetSender());

	env.SendEvent("Elevator::Close", 4, this, ele);
}
开发者ID:ChrisDue,项目名称:Elevator,代码行数:6,代码来源:ElevatorLogic.cpp

示例12: EventView

 EventView(Event const &base) : m_base(base), m_particle(base.coordinate(0))
 {
 }
开发者ID:biel-wro,项目名称:SimBaD,代码行数:3,代码来源:discrete_wave_1d_templ.hpp

示例13: updateAllEvents

//==============================================================================
Error EventManager::updateAllEvents(F32 prevUpdateTime, F32 crntTime)
{
	Error err = ErrorCode::NONE;
	m_prevUpdateTime = prevUpdateTime;
	m_crntTime = crntTime;

	auto it = m_events.getBegin();
	auto end = m_events.getEnd();
	for(; it != end && !err; ++it)
	{
		Event* event = *it;

		// If event or the node's event is marked for deletion then dont 
		// do anything else for that event
		if(event->getMarkedForDeletion())
		{
			continue;
		}

		if(event->getSceneNode() != nullptr 
			&& event->getSceneNode()->getMarkedForDeletion())
		{
			event->setMarkedForDeletion();
			continue;
		}

		// Audjust starting time
		if(event->m_startTime < 0.0)
		{
			event->m_startTime = crntTime;
		}

		// Check if dead
		if(!event->isDead(crntTime))
		{
			// If not dead update it

			if(event->getStartTime() <= crntTime)
			{
				err = event->update(prevUpdateTime, crntTime);
			}
		}
		else
		{
			// Dead

			if(event->getReanimate())
			{
				event->m_startTime = prevUpdateTime;
				err = event->update(prevUpdateTime, crntTime);
			}
			else
			{
				Bool kill;
				err = event->onKilled(prevUpdateTime, crntTime, kill);
				if(!err && kill)
				{
					event->setMarkedForDeletion();
				}
			}
		}
	}

	return err;
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:66,代码来源:EventManager.cpp

示例14: UnRead

void Interactor::UnRead(Event& e) { e.unread(); }
开发者ID:barak,项目名称:ivtools-cvs,代码行数:1,代码来源:interactor.c

示例15: return

bool Event::operator<(const Event& _E) const
{
  if (EventPtr->timeout >= _E.getTimeout())
    return (true);
  return (false);
}
开发者ID:huybuidac,项目名称:yakindu,代码行数:6,代码来源:event.cpp


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