📄 objectmanagement.cc
字号:
// -*- mode:C++ ; tab-width:4 ; c-basic-offset:4 ; indent-tabs-mode:nil -*-// ----------------------------------------------------------------------------// 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.5 2003/02/19 15:45:22 breholee Exp $// ----------------------------------------------------------------------------#include "ObjectManagement.hh"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(){}// -------------------// -- 4.1 requestID --// -------------------voidObjectManagement::requestID(ObjectHandlecount idCount, ObjectHandle &firstID, ObjectHandle &lastID, TypeException &e){ NetworkMessage req, rep ; req.type = m_REQUEST_ID ; req.idCount = idCount ; req.federation = fm->_numero_federation ; req.federate = fm->federate ; comm->sendMessage(&req); comm->waitMessage(&rep, m_REQUEST_ID, req.federate); e = rep.exception ; firstID = rep.firstId ; lastID = rep.lastId ;}// ------------------------// -- 4.2 registerObject --// ------------------------ObjectHandleObjectManagement::registerObject(ObjectClassHandle theClassHandle, const char *theObjectName, FederationTime, FederationTime, TypeException & e){ NetworkMessage req, rep ; req.type = m_REGISTER_OBJECT ; req.federate = fm->federate ; req.federation = fm->_numero_federation ; req.objectClass = theClassHandle ; strcpy(req.label, (char *)theObjectName); // BUG: A quoi servent Date et Heure ? comm->sendMessage(&req); comm->waitMessage(&rep, m_REGISTER_OBJECT, req.federate); e = rep.exception ; if (e == e_NO_EXCEPTION) { rootObject->ObjectClasses->registerInstance(fm->federate, theClassHandle, rep.object, rep.label); // La reponse contient le numero d'objet(object) return rep.object ; } else return 0 ;}// -------------------------------// -- 4.3 updateAttributeValues --// -------------------------------EventRetractionHandleObjectManagement::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 = m_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); // Emission et reception de la reponse comm->sendMessage(&req); comm->waitMessage(&rep, m_UPDATE_ATTRIBUTE_VALUES, req.federate); e = rep.exception ; return rep.eventRetraction ;}// ------------------------// -- 4.4 discoverObject --// ------------------------voidObjectManagement::discoverObject(ObjectHandle theObjectHandle, ObjectClassHandle theObjectClassHandle, const char *theObjectName, FederationTime theTime, EventRetractionHandle theHandle, TypeException &){ Message req, rep ; req.type = DISCOVER_OBJECT ; req.object = theObjectHandle ; req.objectClass = theObjectClassHandle ; req.date = theTime ; req.eventRetraction = theHandle ; req.setName((char *)theObjectName); // BUG: Et on fait quoi de la reponse ? comm->requestFederateService(&req, &rep); // Insertion de l'objet decouvert dans la liste interne du federe rootObject->ObjectClasses->registerInstance(fm->federate, theObjectClassHandle, req.object, req.getName());}// --------------------------------// -- 4.5 reflectAttributeValues --// --------------------------------voidObjectManagement::reflectAttributeValues(ObjectHandle theObjectHandle, AttributeHandle *attribArray, AttributeValue *valueArray, UShort attribArraySize, FederationTime theTime, const char *theTag, EventRetractionHandle theHandle, TypeException &){ Message req, rep ; int i ; req.type = REFLECT_ATTRIBUTE_VALUES ; req.object = theObjectHandle ; req.date = theTime ; req.eventRetraction = theHandle ; req.setTag(theTag); req.handleArraySize = attribArraySize ; for (i = 0 ; i < attribArraySize ; i++) { req.handleArray[i] = attribArray[i] ; req.setValue(i, valueArray[i]); } // BUG: Et on fait quoi de la reponse ? comm->requestFederateService(&req, &rep);}// -------------------------// -- 4.6 sendInteraction --// -------------------------EventRetractionHandleObjectManagement::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 = m_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, m_SEND_INTERACTION, req.federate); e = rep.exception ; return rep.eventRetraction ;}// ----------------------------// -- 4.7 receiveInteraction --// ----------------------------voidObjectManagement::receiveInteraction(InteractionClassHandle theInteraction, ParameterHandle *paramArray, ParameterValue *valueArray, UShort paramArraySize, FederationTime theTime, const char *theTag, EventRetractionHandle theHandle, TypeException &){ int i ; Message req, rep ; req.type = RECEIVE_INTERACTION ; req.interactionClass = theInteraction ; req.date = theTime ; req.eventRetraction = theHandle ; req.setTag(theTag); req.handleArraySize = paramArraySize ; for (i = 0 ; i < paramArraySize ; i++) { req.handleArray[i] = paramArray[i] ; req.setValue(i, valueArray[i]); } // BUG: On fait quoi de la reponse ? comm->requestFederateService(&req, &rep);}// ----------------------// -- 4.8 deleteObject --// ----------------------EventRetractionHandleObjectManagement::deleteObject(ObjectHandle theObjectHandle, const char *theTag, TypeException &e){ NetworkMessage req, rep ; req.type = m_DELETE_OBJECT ; req.object = theObjectHandle ; req.federation = fm->_numero_federation ; req.federate = fm->federate ; strcpy(req.label, theTag); comm->sendMessage(&req);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -