ProvideAttributeValueUpdatePR::ProvideAttributeValueUpdatePR (RTI::ObjectHandle oid, const RTI::AttributeHandleSet & attr) : objid (oid), size (attr.size ()) { handleSet = new RTI::AttributeHandle [size]; if (handleSet == NULL) { cerr << "Unable to create array of attribute handles, can't process attribute update request" << endl; size = 0; return; } for (int i = 0; i < size; i++) { handleSet[i] = attr.getHandle (i); } }
void HwFederateAmbassador::provideAttributeValueUpdate ( RTI::ObjectHandle theObject, // supplied C1 const RTI::AttributeHandleSet& theAttributes) // supplied C4 throw ( RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeNotOwned, RTI::FederateInternalError) { //----------------------------------------------------------------- // Find the Country instance this request is for. //----------------------------------------------------------------- Country *pCountry = Country::Find( theObject ); if ( pCountry ) { //----------------------------------------------------------------- // Touch the appropriate attribute values in this country // instance so that the get updated next cycle. //----------------------------------------------------------------- RTI::AttributeHandle attrHandle; //----------------------------------------------------------------- // We need to iterate through the AttributeHandleSet // to extract each AttributeHandle. Based on the type // specified ( the value returned by getHandle() ) we need to // set the status of whether we should send this type of data. //----------------------------------------------------------------- for (unsigned int i = 0; i < theAttributes.size(); i++ ) { attrHandle = theAttributes.getHandle( i ); if ( attrHandle == Country::GetPopulationRtiId() ) { // Touch population so that it gets update next cycle pCountry->SetPopulation( pCountry->GetPopulation() ); } else if ( attrHandle == Country::GetNameRtiId() ) { // Touch name so that it gets update next cycle pCountry->SetName( pCountry->GetName() ); } } } }
void CFellow::FellowUpdateControl(RTI::Boolean status, const RTI::AttributeHandleSet& theAttrHandles) { RTI::AttributeHandle attrHandle; for (unsigned int i = 0; i < theAttrHandles.size(); i++) { attrHandle = theAttrHandles.getHandle(i); if (attrHandle == CFellow::GetFellowNameRtiId()) { m_bNameChanged = status; } else if (attrHandle == CFellow::GetFellowColorRtiId()) { m_bColorChanged = status; } else if (attrHandle == CFellow::GetFellowPortraitRtiId()) { m_bPortraitChanged = status; } } }