⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectmanagement.cc

📁 分布式仿真 开放源码
💻 CC
📖 第 1 页 / 共 2 页
字号:
// ----------------------------------------------------------------------------// CERTI - HLA RunTime Infrastructure// Copyright (C) 2002, 2003  ONERA//// This file is part of CERTI//// CERTI is free software ; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation ; either version 2 of the License, or// (at your option) any later version.//// CERTI is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY ; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program ; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//// $Id: ObjectManagement.cc,v 3.14 2004/01/09 16:41:00 breholee Exp $// ----------------------------------------------------------------------------#include <config.h>#include "ObjectManagement.hh"#include "FederationManagement.hh"#include "PrettyDebug.hh"#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdlib.h>#include <iostream>using std::cout ;using std::endl ;namespace certi {namespace rtia {static pdCDebug D("RTIA_OM", "(RTIA OM) ");ObjectManagement::ObjectManagement(Communications *GC,                                   FederationManagement *GF,                                   RootObject *theRootObj)    : comm(GC),       fm(GF),      rootObject(theRootObj) { }ObjectManagement::~ObjectManagement() { }// ----------------------------------------------------------------------------//! registerObjectObjectHandleObjectManagement::registerObject(ObjectClassHandle the_class,                                 const char *theObjectName,                                 FederationTime,                                 FederationTime,                                 TypeException & e){    NetworkMessage req, rep ;    req.type = NetworkMessage::REGISTER_OBJECT ;    req.federate = fm->federate ;    req.federation = fm->_numero_federation ;    req.objectClass = the_class ;    strcpy(req.label, (char *) theObjectName);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::REGISTER_OBJECT, req.federate);    e = rep.exception ;    if (e == e_NO_EXCEPTION) {        rootObject->registerObjectInstance(fm->federate, the_class, rep.object,                                           rep.label);        return rep.object ;    }    else        return 0 ;}// ----------------------------------------------------------------------------//! updateAttributeValuesEventRetractionHandleObjectManagement::updateAttributeValues(ObjectHandle theObjectHandle,                                        AttributeHandle *attribArray,                                        AttributeValue *valueArray,                                        UShort attribArraySize,                                        FederationTime theTime,                                        const char *theTag,                                        TypeException &e){    NetworkMessage req, rep ;    int i ;    // Mise en place de la requete    req.type = NetworkMessage::UPDATE_ATTRIBUTE_VALUES ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObjectHandle ;    req.date = theTime ;    req.handleArraySize = attribArraySize ;    for (i = 0 ; i < attribArraySize ; i++) {        req.handleArray[i] = attribArray[i] ;        req.setValue(i, valueArray[i]);    }    strcpy(req.label, theTag);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::UPDATE_ATTRIBUTE_VALUES, req.federate);    e = rep.exception ;    return rep.eventRetraction ;}// ----------------------------------------------------------------------------//! discoverObject.voidObjectManagement::discoverObject(ObjectHandle the_object,                                 ObjectClassHandle the_class,                                 const char *the_name,                                 FederationTime the_time,                                 EventRetractionHandle the_event,                                 TypeException &){    Message req, rep ;    req.type = Message::DISCOVER_OBJECT_INSTANCE ;    req.setObject(the_object);    req.setObjectClass(the_class);    req.setFederationTime(the_time);    req.setEventRetraction(the_event);    req.setName(the_name);    comm->requestFederateService(&req, &rep);    // Adding discovered object in federate internal object list.    rootObject->registerObjectInstance(fm->federate, the_class, the_object,                                       req.getName());}// ----------------------------------------------------------------------------//! reflectAttributeValues.voidObjectManagement::reflectAttributeValues(ObjectHandle the_object,                                         AttributeHandle *the_attributes,                                         AttributeValue *the_values,                                         UShort the_size,                                         FederationTime the_time,                                         const char *the_tag,                                         EventRetractionHandle the_event,                                         TypeException &){    Message req, rep ;    req.type = Message::REFLECT_ATTRIBUTE_VALUES ;    req.setObject(the_object);    req.setFederationTime(the_time);    req.setEventRetraction(the_event);    req.setTag(the_tag);    req.setAttributes(the_attributes, the_values, the_size);    comm->requestFederateService(&req, &rep);}// ----------------------------------------------------------------------------//! sendInteractionEventRetractionHandleObjectManagement::sendInteraction(InteractionClassHandle theInteraction,                                  ParameterHandle *paramArray,                                  ParameterValue *valueArray,                                  UShort paramArraySize,                                  FederationTime theTime,                                  const char *theTag,                                  TypeException &e){    NetworkMessage req, rep ;    // Test local pour savoir si l'interaction est correcte.    rootObject->Interactions->isReady(fm->federate,                                      theInteraction,                                      paramArray,                                      paramArraySize);    // Preparation du message au RTI.    req.type = NetworkMessage::SEND_INTERACTION ;    req.interactionClass = theInteraction ;    req.date = theTime ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.handleArraySize = paramArraySize ;    for (int i=0 ; i<paramArraySize ; i++)        {            req.handleArray[i] = paramArray[i] ;            req.setValue(i, valueArray[i]);        }    strcpy(req.label, theTag);    // Emission et attente de la reponse.    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::SEND_INTERACTION, req.federate);    e = rep.exception ;    return rep.eventRetraction ;}// ----------------------------------------------------------------------------//! receiveInteractionvoidObjectManagement::receiveInteraction(InteractionClassHandle the_interaction,                                     ParameterHandle *the_parameters,                                     ParameterValue *the_values,                                     UShort the_size,                                     FederationTime the_time,                                     const char *the_tag,                                     EventRetractionHandle the_event,                                     TypeException &){    Message req, rep ;    req.type = Message::RECEIVE_INTERACTION ;    req.setInteractionClass(the_interaction);    req.setFederationTime(the_time);    req.setEventRetraction(the_event);    req.setTag(the_tag);    req.setParameters(the_parameters, the_values, the_size);    // BUG: On fait quoi de la reponse ?    comm->requestFederateService(&req, &rep);}// ----------------------------------------------------------------------------//! deleteObjectEventRetractionHandleObjectManagement::deleteObject(ObjectHandle theObjectHandle,                               const char *theTag,                               TypeException &e){    NetworkMessage req, rep ;    req.type = NetworkMessage::DELETE_OBJECT ;    req.object = theObjectHandle ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    strcpy(req.label, theTag);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::DELETE_OBJECT, req.federate);    e = rep.exception ;    if (e == e_NO_EXCEPTION)        rootObject->ObjectClasses->deleteObject(fm->federate,                                                theObjectHandle,                                                theTag);    return rep.eventRetraction ;}// ----------------------------------------------------------------------------//! removeObjectvoidObjectManagement::removeObject(ObjectHandle the_object,                               FederateHandle the_federate,                               const char *the_tag,                               EventRetractionHandle the_event,                               TypeException &){    Message req, rep ;    req.type = Message::REMOVE_OBJECT_INSTANCE ;    req.setObject(the_object);    req.setEventRetraction(the_event);    req.setTag(the_tag);    // BUG: On fait quoi de la reponse ?    comm->requestFederateService(&req, &rep);    rootObject->ObjectClasses->deleteObject(the_federate, the_object, the_tag);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -