本文整理汇总了C++中EventInfo::setTo方法的典型用法代码示例。如果您正苦于以下问题:C++ EventInfo::setTo方法的具体用法?C++ EventInfo::setTo怎么用?C++ EventInfo::setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventInfo
的用法示例。
在下文中一共展示了EventInfo::setTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFullDataFile
/// [11/19/2008 by Guanhua Yan. ]
///
/// reads info from input file <Time> <EntityID> <ServiceAddr>
/// <InfoType> <info data .....> without any time constraints. Open a
/// file and then read all infos.
///≈
void InfoManager::readFullDataFile(const std::string& infoFiles )
{
assert(false);
/// these variables should be static because they will be reused may times
static const Control::LpPtrMap& lpMap = Control::getLpPtrMap();
SMART_ASSERT( lpMap.begin() != lpMap.end() );
SMART_ASSERT( lpMap.begin()->second );
static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node
Time now = lp.getNow();
#ifdef DEBUG
Logger::debug3() << "InfoManager: in readFullDataFile at time " << now
<< ", infoFiles= " << infoFiles << endl;
#endif
stringstream sstr;
sstr << infoFiles;
string fileName;
// for each file, setup a reader
while( sstr >> fileName )
{
InfoData::Reader reader(fileName);
while ( reader.MoreData()) {
InfoData data( reader.ReadData() );
// see if we will send the info:
LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() );
Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId);
if( lpIter != lpMap.end() )
{
// the destination resides on one of LPs in this Unix process
// send the info:
#ifdef DEBUG
Logger::debug3() << "InfoManager: processing data: " << data << endl;
#endif
// get info object and fill it with data
boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getData() ) );
boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input);
SMART_ASSERT( info ); /// the object MUST actually be a descendant of Info
#ifdef DEBUG
Logger::debug3() << "InfoManager: processing info: " << info << endl;
#endif
// set EventInfo parameters:
EventInfo event;
event.setTo( data.getEntityId(), data.getServiceAddress() );
event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now ));
event.setInfo( info );
// send it off directly to the right LP
LP* lpPointer = lpIter->second;
SMART_ASSERT( lpPointer );
lpPointer->sendEventInfo(event);
} // else don't schedule it, other Unix process will
} // while(MoreData)
}
}
示例2: processOutgoingInfo
void Entity::processOutgoingInfo(const boost::shared_ptr<const Info> info, const Time& delay, const EntityID& dest, const ServiceAddress& serv) const
{
if(Control::getSimPhase() != Control::kPhaseRun) {
Logger::failure("Entity::processOutgoingInfo(): simulation not running!");
}
EventInfo event;
event.setTo(dest, serv);
event.setDelay(delay);
event.setInfo(info);
// send it off
fLP.sendEventInfo( event );
}
示例3: createPyInfoFromInfoData
void InfoManager::createPyInfoFromInfoData( PyInfoData& data ) {
static const Control::LpPtrMap& lpMap = Control::getLpPtrMap();
static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node
Time now = lp.getNow();
// see if we will send the info:
LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() );
Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId);
if( lpIter != lpMap.end() )
{
// the destination resides on one of LPs in this Unix process
// send the info:
#ifdef DEBUG
Logger::debug3() << "InfoManager: processing data: " << data << endl;
#endif
// get info object and fill it with data
boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getProfile(), data.getData() ) );
boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input);
SMART_ASSERT( info ); /// the object MUST actually be a descendant of Info
#ifdef DEBUG
Logger::debug3() << "InfoManager: processing info: " << info << endl;
#endif
// set EventInfo parameters:
EventInfo event;
event.setTo( data.getEntityId(), data.getServiceAddress() );
if( data.getTime() < now )
Logger::warn() << "InfoManager: Sending event at time " << now
<< " which should have been sent at " << data.getTime()
<< " : Check if input is time sorted " << endl;
event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now ));
event.setInfo( info );
// send it off directly to the right LP
LP* lpPointer = lpIter->second;
SMART_ASSERT( lpPointer );
lpPointer->sendEventInfo(event);
} // else don't schedule it, other Unix process will
}