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


C++ GlobalEvent类代码示例

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


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

示例1: execute

void GlobalEvents::execute(GlobalEvent_t type) const
{
	for (const auto& it : serverMap) {
		GlobalEvent* globalEvent = it.second;
		if (globalEvent->getEventType() == type) {
			globalEvent->executeEvent();
		}
	}
}
开发者ID:kinglekke,项目名称:forgottenserver,代码行数:9,代码来源:globalevent.cpp

示例2: execute

void GlobalEvents::execute(GlobalEvent_t type)
{
	for (GlobalEventMap::iterator it = serverMap.begin(); it != serverMap.end(); ++it) {
		GlobalEvent* globalEvent = it->second;
		if (globalEvent->getEventType() == type) {
			globalEvent->executeEvent();
		}
	}
}
开发者ID:afsdadsfdsa,项目名称:forgottenserver,代码行数:9,代码来源:globalevent.cpp

示例3: if

bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
	GlobalEvent* globalEvent = reinterpret_cast<GlobalEvent*>(event);
	if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
		GlobalEventMap::iterator it = timerMap.find(globalEvent->getName());
		if (it == timerMap.end()) {
			timerMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			if (timerEventId == 0) {
				timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
			}

			return true;
		}
	} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
		GlobalEventMap::iterator it = serverMap.find(globalEvent->getName());
		if (it == serverMap.end()) {
			serverMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			return true;
		}
	} else { // think event
		auto it = thinkMap.find(globalEvent->getName());
		if (it == thinkMap.end()) {
			thinkMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			if (thinkEventId == 0) {
				thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
			}
			return true;
		}
	}

	std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
	return false;
}
开发者ID:godely,项目名称:forgottenserver,代码行数:33,代码来源:globalevent.cpp

示例4: getClassKey

void 
OPRijVij::eventUpdate(const GlobalEvent& globEvent, const NEventData& SDat)
{
  BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges)
    process2PED(rvdotacc[mapKey(globEvent.getType(), getClassKey(globEvent))],
		pDat);
}
开发者ID:herbsolo,项目名称:DynamO,代码行数:7,代码来源:rijvijdirection.cpp

示例5: stream

 void 
 OPViscosityE::eventUpdate(const GlobalEvent& iEvent, const NEventData& PDat) 
 {
   stream(iEvent.getdt());
   impulseDelG(PDat);
   updateConstDelG(PDat);
 }
开发者ID:armando-2011,项目名称:DynamO,代码行数:7,代码来源:viscosityE.cpp

示例6: stream

  void 
  OPThermalDiffusionE::eventUpdate(const GlobalEvent& iEvent, 
				   const NEventData& PDat) 
  {
    stream(iEvent.getdt());
    delG += impulseDelG(PDat);
    updateConstDelG(PDat);
  }
开发者ID:armando-2011,项目名称:DynamO,代码行数:8,代码来源:thermaldiffE.cpp

示例7: stream

  void 
  OPThermalConductivitySpeciesSpeciesE::eventUpdate(const GlobalEvent& iEvent, 
						    const NEventData& PDat) 
  {
    stream(iEvent.getdt());
    //impulseDelG(PDat);
    updateConstDelG(PDat);
  }
开发者ID:pviswanathan,项目名称:DynamO,代码行数:8,代码来源:thermalCondSpeciesSpeciesE.cpp

示例8: OTSYS_TIME

void GlobalEvents::think()
{
	int64_t now = OTSYS_TIME();

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();
	for (const auto& it : thinkMap) {
		GlobalEvent* globalEvent = it.second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			continue;
		}

		if (!globalEvent->executeEvent()) {
			std::cout << "[Error - GlobalEvents::think] Failed to execute event: " << globalEvent->getName() << std::endl;
		}

		nextExecutionTime = globalEvent->getInterval();
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		thinkEventId = g_scheduler->addEvent(createSchedulerTask(std::max<int64_t>(SCHEDULER_MINTICKS, nextScheduledTime),
											std::bind(&GlobalEvents::think, this)));
	}
}
开发者ID:kinglekke,项目名称:forgottenserver,代码行数:34,代码来源:globalevent.cpp

示例9: time

void GlobalEvents::timer()
{
	time_t now = time(nullptr);

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();

	auto it = timerMap.begin();
	while (it != timerMap.end()) {
		GlobalEvent* globalEvent = it->second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			++it;
			continue;
		}

		if (!globalEvent->executeEvent()) {
			it = timerMap.erase(it);
			continue;
		}

		nextExecutionTime = 86400;
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);

		++it;
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		timerEventId = g_scheduler->addEvent(createSchedulerTask(std::max<int64_t>(1000, nextScheduledTime * 1000),
							                std::bind(&GlobalEvents::timer, this)));
	}
}
开发者ID:kinglekke,项目名称:forgottenserver,代码行数:40,代码来源:globalevent.cpp

示例10: if

bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
	GlobalEvent* globalEvent = static_cast<GlobalEvent*>(event); //event is guaranteed to be a GlobalEvent
	if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
		auto result = timerMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			if (timerEventId == 0) {
				timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
			}
			return true;
		}
	} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
		auto result = serverMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			return true;
		}
	} else { // think event
		auto result = thinkMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			if (thinkEventId == 0) {
				thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
			}
			return true;
		}
	}

	std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
	return false;
}
开发者ID:Caduceus,项目名称:DecapitatedSoul,代码行数:29,代码来源:globalevent.cpp

示例11: while

  void 
  OPVACF::eventUpdate(const GlobalEvent& iEvent, const NEventData& PDat) 
  {
    //Move the time forward
    currentdt += iEvent.getdt();
  
    //Now test if we've gone over the step time
    while (currentdt >= dt)
      {
	currentdt -= dt;
	newG(PDat);
      }
  }
开发者ID:armando-2011,项目名称:DynamO,代码行数:13,代码来源:vacf.cpp

示例12: stream

  void
  OPMisc::eventUpdate(const GlobalEvent& eevent, const NEventData& NDat)
  {
    stream(eevent.getdt());
    eventUpdate(NDat);

    BOOST_FOREACH(const ParticleEventData& pData, NDat.L1partChanges)
      newEvent(pData.getParticleID(), pData.getType(), getClassKey(eevent));

    BOOST_FOREACH(const PairEventData& pData, NDat.L2partChanges)
      {
	newEvent(pData.particle1_.getParticleID(), pData.getType(), getClassKey(eevent));
	newEvent(pData.particle2_.getParticleID(), pData.getType(), getClassKey(eevent));
      }
  }
开发者ID:dhouhadhouha,项目名称:DynamO,代码行数:15,代码来源:misc.cpp

示例13: getClassKey

void 
OPCubeComp::eventUpdate(const GlobalEvent& globEvent, const NEventData& SDat)
{
  BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges)
    {
      mapdata& ref = angles[mapKey(globEvent.getType(), 
				   getClassKey(globEvent))];
      std::vector<double> vals(NDIM, 0);
      
      for (size_t i(0); i < NDIM; ++i)
	vals[i] = pDat.rij[i] * pDat.rij[i] / Sim->dynamics.units().unitArea();
      
      std::sort(vals.begin(), vals.end());
      
      for (size_t i(0); i < NDIM; ++i)
	ref.angles[i].addVal(vals[i]);
    }
}
开发者ID:herbsolo,项目名称:DynamO,代码行数:18,代码来源:cubecomponents.cpp

示例14: time

void GlobalEvents::timer()
{
	time_t now = time(nullptr);

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();

	auto it = timerMap.begin();
	while (it != timerMap.end()) {
		GlobalEvent* globalEvent = it->second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			++it;
			continue;
		}

		if (!globalEvent->executeEvent()) {
			std::cout << "[Error - GlobalEvents::timer] Failed to execute event: " << globalEvent->getName() << std::endl;
		}

		if (g_config.getBoolean(ConfigManager::SHUTDOWN_AT_SERVERSAVE)) {
			it = timerMap.erase(it);
			continue;
		}

		nextExecutionTime = 86400;
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);

		++it;
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		timerEventId = g_scheduler.addEvent(createSchedulerTask(std::max<int64_t>(1000, nextScheduledTime * 1000),
							                boost::bind(&GlobalEvents::timer, this)));
	}
}
开发者ID:AhmedWaly,项目名称:forgottenserver,代码行数:44,代码来源:globalevent.cpp

示例15: stream

 void 
 OPCollTicker::eventUpdate(const GlobalEvent &event, const NEventData&) 
 {
   stream(event.getdt());
   ticker();
 }
开发者ID:armando-2011,项目名称:DynamO,代码行数:6,代码来源:collticker.cpp


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