📄 message.cc
字号:
// ----------------------------------------------------------------------------voidMessage::setAHS(const AttributeHandle *attr, int size){ handleArraySize = size ; for (int i = 0 ; i < size ; ++i) { handleArray[i] = attr[i] ; }}// ----------------------------------------------------------------------------voidMessage::setRegions(const RegionImp **reg, int size){ regions.resize(size); for (int i = 0 ; i < size ; ++i) { regions[i] = reg[i]->getHandle(); }}// ----------------------------------------------------------------------------AttributeHandleValuePairSet*Message::getAHVPS() const{ CAttributeHandleValuePairSet * theAttributes ; theAttributes = new CAttributeHandleValuePairSet ; for (int i = 0 ; i < handleArraySize ; i++) { CAttributeHandleValuePair *att = new CAttributeHandleValuePair ; att->_attrib = handleArray[i] ; // BUG: Federate may be expecting to find value name // (a call to GetWithName for example). strcpy(att->_value.name, ""); getValue(i, att->_value.value); // BUG: Federate is expecting to find value type. strcpy(att->_value.type, ""); theAttributes->add(att); } return theAttributes->toAHVPS();}// ----------------------------------------------------------------------------voidMessage::setAHVPS(const AttributeHandleValuePairSet &the_attributes){ ULong length ; CAttributeHandleValuePairSet *theAttributes_aux ; theAttributes_aux = new CAttributeHandleValuePairSet(the_attributes); CAttributeHandleValuePair *tmp ; handleArraySize = theAttributes_aux->_size ; for (int i = 0 ; i < theAttributes_aux->_size ; i++) { tmp = theAttributes_aux->getIeme(i); handleArray[i] = tmp->_attrib ; // codage getObjectToStringLength(tmp->_value.value, tmp->_value.length, length); char *value = new char[length] ; objectToString(tmp->_value.value, tmp->_value.length, value); setValue(i, value); } delete theAttributes_aux ;}// ----------------------------------------------------------------------------ParameterHandleValuePairSet*Message::getPHVPS() const{ CParameterHandleValuePairSet* theParameters ; theParameters = new CParameterHandleValuePairSet ; for (int i = 0 ; i < handleArraySize ; i++) { CParameterHandleValuePair *par = new CParameterHandleValuePair ; par->_param = handleArray[i] ; // BUG: Federate may be expecting to find value name // (a call to GetWithName for example). strcpy(par->_value.name, ""); getValue(i, par->_value.value); // BUG: Federate is expecting to find value type. strcpy(par->_value.type, ""); theParameters->add(par); } return theParameters->toPHVPS();}// ----------------------------------------------------------------------------voidMessage::setPHVPS(const ParameterHandleValuePairSet &the_parameters){ ULong length ; CParameterHandleValuePairSet *theParameters_aux ; theParameters_aux = new CParameterHandleValuePairSet(the_parameters); CParameterHandleValuePair *tmp ; handleArraySize = theParameters_aux->_size ; for (int i = 0 ; i < theParameters_aux->_size ; i++) { tmp = theParameters_aux->getIeme(i); handleArray[i] = tmp->_param ; // codage getObjectToStringLength(tmp->_value.value, tmp->_value.length, length); char *value = new char[length] ; objectToString(tmp->_value.value, tmp->_value.length, value); setValue(i, value); } delete theParameters_aux ;}// ----------------------------------------------------------------------------voidMessage::setAttributes(AttributeHandle *the_attributes, ushort the_size){ handleArraySize = the_size ; for (int i = 0 ; i < the_size ; i++) { handleArray[i] = the_attributes[i] ; }}// ----------------------------------------------------------------------------voidMessage::setAttributes(AttributeHandle *the_attributes, AttributeValue *the_values, ushort the_size){ handleArraySize = the_size ; for (int i = 0 ; i < the_size ; i++) { handleArray[i] = the_attributes[i] ; setValue(i, the_values[i]); }}// ----------------------------------------------------------------------------voidMessage::setParameters(ParameterHandle * the_parameters, ParameterValue * the_values, ushort the_size){ handleArraySize = the_size ; for (int i = 0 ; i < the_size ; i++) { handleArray[i] = the_parameters[i] ; setValue(i, the_values[i]); }}// ----------------------------------------------------------------------------//! Sets the federation name.void Message::setFederationName(const char *NewNomFederation){ if (strlen(NewNomFederation) > MAX_FEDERATION_NAME_LENGTH) throw ValueLengthExceeded("NomFederation too long to fit in Message."); strcpy(federationName, NewNomFederation);}// ----------------------------------------------------------------------------// setFederateName//voidMessage::setFederateName(const char *NewNomFedere){ if (strlen(NewNomFedere) > MAX_FEDERATE_NAME_LENGTH) throw ValueLengthExceeded("NomFedere too long to fit in Message."); strcpy(federateName, NewNomFedere);}// ----------------------------------------------------------------------------// setTag//voidMessage::setTag(const char *new_tag){ if (new_tag) { if (strlen(new_tag) > MAX_USER_TAG_LENGTH) { throw ValueLengthExceeded("Tag too long to fit in Message."); } strcpy(tag, new_tag); } else { strcpy(tag, ""); }}// ----------------------------------------------------------------------------// setValue//voidMessage::setValue(int Rank, const char *Value) throw (RTIinternalError){ // Pre-Checking if ((Value == NULL) || (strlen(Value) > MAX_BYTES_PER_VALUE)) throw RTIinternalError("Bad Value for message."); if ((Rank < 0) || (Rank >= handleArraySize)) throw RTIinternalError("Bad Rank for message."); // Setting Value strcpy(valueArray[Rank], Value);}// ----------------------------------------------------------------------------// operator=//Message &Message::operator=(const Message& msg){ type = msg.type ; date = msg.date ; boolean = msg.boolean ; lookahead = msg.lookahead ; exception = msg.exception ; strcpy(exceptionReason, msg.exceptionReason); strcpy(federateName, msg.federateName); strcpy(federationName, msg.federationName); federate = msg.federate ; resignAction = msg.resignAction ; idCount = msg.idCount ; firstId = msg.firstId ; lastId = msg.lastId ; objectClass = msg.objectClass ; interactionClass = msg.interactionClass ; attribute = msg.attribute ; parameter = msg.parameter ; object = msg.object ; space = msg.space ; dimension = msg.dimension ; // transportation = msg.transportation ; // ordering = msg.ordering ; strcpy(tag, msg.tag); strcpy(name, msg.name); transport = msg.transport ; order = msg.order ; eventRetraction.theEventTime = msg.eventRetraction.theEventTime ; eventRetraction.theSerialNumber = msg.eventRetraction.theSerialNumber ; eventRetraction.sendingFederate = msg.eventRetraction.sendingFederate ; strcpy(label, msg.label); handleArraySize = msg.handleArraySize ; int i ; for (i=0 ; i < handleArraySize ; i++) handleArray[i] = msg.handleArray[i] ; for (i=0 ; i<<handleArraySize ; i++) strcpy(valueArray[i], msg.valueArray[i]); return *this ;}// ----------------------------------------------------------------------------// display//voidMessage::display(char *s){ printf(" --- MESSAGE --- %s ---\n", s); printf(" type=%d:\n", type); printf(" date=%f:\n", date); printf(" exception=%d:\n", exception); printf(" objectClass=%ld:\n", objectClass); printf(" interactionClass=%ld:\n", interactionClass); printf(" attribute=%ld:\n", attribute); printf(" parameter=%ld:\n", parameter); printf(" object=%ld:\n", object); printf(" handleArraySize=%d:\n", handleArraySize); printf(" space %ld:\n", space); printf(" dimension %ld:\n", dimension); // printf(" transportation %d:\n", transportation); // printf(" ordering %d:\n", ordering);}} // namespace certi// $Id: Message.cc,v 3.23 2003/11/10 14:43:01 breholee Exp $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -