本文整理汇总了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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例5: stream
void
OPViscosityE::eventUpdate(const GlobalEvent& iEvent, const NEventData& PDat)
{
stream(iEvent.getdt());
impulseDelG(PDat);
updateConstDelG(PDat);
}
示例6: stream
void
OPThermalDiffusionE::eventUpdate(const GlobalEvent& iEvent,
const NEventData& PDat)
{
stream(iEvent.getdt());
delG += impulseDelG(PDat);
updateConstDelG(PDat);
}
示例7: stream
void
OPThermalConductivitySpeciesSpeciesE::eventUpdate(const GlobalEvent& iEvent,
const NEventData& PDat)
{
stream(iEvent.getdt());
//impulseDelG(PDat);
updateConstDelG(PDat);
}
示例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)));
}
}
示例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)));
}
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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]);
}
}
示例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)));
}
}
示例15: stream
void
OPCollTicker::eventUpdate(const GlobalEvent &event, const NEventData&)
{
stream(event.getdt());
ticker();
}