本文整理汇总了C++中NetIO::findAttributeIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ NetIO::findAttributeIndex方法的具体用法?C++ NetIO::findAttributeIndex怎么用?C++ NetIO::findAttributeIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetIO
的用法示例。
在下文中一共展示了NetIO::findAttributeIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reflectAttributeValues
//------------------------------------------------------------------------------
// reflectAttributeValues() -- (Input support)
// Called by our FederateAmbassador to update the attribute values for
// this object instance. (Also handles the network to host byte swapping)
//------------------------------------------------------------------------------
void Nib::reflectAttributeValues(const RTI::AttributeHandleValuePairSet& theAttrs)
{
NetIO* netIO = static_cast<NetIO*>(getNetIO());
if (netIO != nullptr && baseEntity != nullptr) {
// PhysicalEntity pointer
PhysicalEntity* physicalEntity = dynamic_cast<PhysicalEntity*>(baseEntity);
RTI::ULong length;
char netBuffer[1000];
for (RTI::ULong j = 0; j < theAttrs.size(); j++ ) {
// get the attribute's handle and data (network byte order)
RTI::AttributeHandle theAttr = theAttrs.getHandle(j);
theAttrs.getValue(j, netBuffer, length);
// Process the attribute
switch ( netIO->findAttributeIndex(theAttr) ) {
// Update Federate ID
case NetIO::ENTITY_IDENTIFIER_AI : {
EntityIdentifierStruct* net = reinterpret_cast<EntityIdentifierStruct*>(&netBuffer);
base::NetHandler::fromNetOrder(&baseEntity->entityIdentifier.federateIdentifier.applicationID, net->federateIdentifier.applicationID );
base::NetHandler::fromNetOrder(&baseEntity->entityIdentifier.federateIdentifier.siteID, net->federateIdentifier.siteID );
base::NetHandler::fromNetOrder(&baseEntity->entityIdentifier.entityNumber, net->entityNumber );
setAttributeUpdateRequiredFlag(NetIO::ENTITY_IDENTIFIER_AI, true);
}
break;
// Update Entity Type
case NetIO::ENTITY_TYPE_AI : {
EntityTypeStruct* net = reinterpret_cast<EntityTypeStruct*>(&netBuffer);
// All bytes except for country
baseEntity->entityType = *net;
base::NetHandler::fromNetOrder(&baseEntity->entityType.countryCode, net->countryCode );
setAttributeUpdateRequiredFlag(NetIO::ENTITY_TYPE_AI, true);
}
break;
// Update Spatial
case NetIO::SPATIAL_AI : {
// NIB's base entity structure pointers
SpatialStruct* spatial = &(baseEntity->spatial);
SpatialRVStruct* spatialRvw = &(baseEntity->spatialRvw);
WorldLocationStruct* worldLocation = &spatialRvw->worldLocation;
OrientationStruct* orientation = &spatialRvw->orientation;
VelocityVectorStruct* velocityVector = &spatialRvw->velocityVector;
AccelerationVectorStruct* accelerationVector = &spatialRvw->accelerationVector;
AngularVelocityVectorStruct* angularVelocity = &spatialRvw->angularVelocity;
// Net buffer component pointers
SpatialStruct* netSpatial = reinterpret_cast<SpatialStruct*>(&netBuffer[0]);
WorldLocationStruct* netWorldLocation = nullptr;
OrientationStruct* netOrientation = nullptr;
VelocityVectorStruct* netVelocityVector = nullptr;
AccelerationVectorStruct* netAccelerationVector = nullptr;
AngularVelocityVectorStruct* netAngularVelocity = nullptr;
// Dead reckoning
spatial->deadReckoningAlgorithm = netSpatial->deadReckoningAlgorithm;
// find network components based on dead reckoning algorithm
// (and set the isFrozen flag)
switch (spatial->deadReckoningAlgorithm) {
case DRM_STATIC : {
SpatialStaticStruct* netSpatialStatic = reinterpret_cast<SpatialStaticStruct*>(&netBuffer[sizeof(SpatialStruct)]);
spatialRvw->isFrozen = netSpatialStatic->isFrozen;
netWorldLocation = &netSpatialStatic->worldLocation;
netOrientation = &netSpatialStatic->orientation;
}
break;
case DRM_FPW : {
SpatialFPStruct* netSpatialFpw = reinterpret_cast<SpatialFPStruct*>(&netBuffer[sizeof(SpatialStruct)]);
spatialRvw->isFrozen = netSpatialFpw->isFrozen;
netWorldLocation = &netSpatialFpw->worldLocation;
netOrientation = &netSpatialFpw->orientation;
netVelocityVector = &netSpatialFpw->velocityVector;
}
break;
case DRM_RPW : {
SpatialRPStruct* netSpatialRpw = reinterpret_cast<SpatialRPStruct*>(&netBuffer[sizeof(SpatialStruct)]);
spatialRvw->isFrozen = netSpatialRpw->isFrozen;
netWorldLocation = &netSpatialRpw->worldLocation;
netOrientation = &netSpatialRpw->orientation;
netVelocityVector = &netSpatialRpw->velocityVector;
netAngularVelocity = &netSpatialRpw->angularVelocity;
}
//.........这里部分代码省略.........