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

📄 ownershipmanagement.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: OwnershipManagement.cc,v 3.8 2003/06/27 17:26:28 breholee Exp $// ----------------------------------------------------------------------------#include <config.h>#include "OwnershipManagement.hh"#include "PrettyDebug.hh"#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdlib.h>namespace certi {namespace rtia {static pdCDebug D("RTIA_OWM", "(RTIA OwM) ");// ----------------------------------------------------------------------------//! Constructor.OwnershipManagement::OwnershipManagement(Communications *GC,                                         FederationManagement *GF){    comm = GC ;    fm = GF ;}// ----------------------------------------------------------------------------//! Destructor.OwnershipManagement::~OwnershipManagement(){}// ----------------------------------------------------------------------------//! isAttributeOwnedByFederate.const char *OwnershipManagement::attributeOwnedByFederate(ObjectHandle theObject,                                              AttributeHandle theAttribute,                                              TypeException &e){    NetworkMessage req, rep ;    D.Out(pdDebug,          "IS_ATTRIBUTE_OWNED_BY_FEDERATE, attribute %u of object %u",          theAttribute, theObject);    req.type = NetworkMessage::IS_ATTRIBUTE_OWNED_BY_FEDERATE ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArray[0] = theAttribute ;    req.handleArraySize = 1 ;    D.Out(pdDebug, "Federate %u ", fm->federate);    comm->sendMessage(&req);    // waitMessage is only used to verify transmission was OK.    comm->waitMessage(&rep,                      NetworkMessage::IS_ATTRIBUTE_OWNED_BY_FEDERATE,                      req.federate);    e = rep.exception ;    if (e == e_NO_EXCEPTION)        return(rep.label);    else        return("\0");}// ----------------------------------------------------------------------------//! queryAttributeOwnership.voidOwnershipManagement::queryAttributeOwnership(ObjectHandle theObject,                                             AttributeHandle theAttribute,                                             TypeException &e){    NetworkMessage req, rep ;    D.Out(pdDebug,          "QUERY_ATTRIBUTE_OWNERSHIP, attribute %u from object %u",          theAttribute, theObject);    req.type = NetworkMessage::QUERY_ATTRIBUTE_OWNERSHIP ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArray[0] = theAttribute ;    req.handleArraySize = 1 ;    D.Out(pdDebug, "Federate %u ", fm->federate);    comm->sendMessage(&req);    //AttendreMsg ne sert que pour verifier que la transmission a ete OK    comm->waitMessage(&rep, NetworkMessage::QUERY_ATTRIBUTE_OWNERSHIP, req.federate);    e = rep.exception ;}// ----------------------------------------------------------------------------//! negotiatedAttributeOwnershipDivestiture.voidOwnershipManagement::negotiatedAttributeOwnershipDivestiture(ObjectHandle theObject,                                        AttributeHandle *attribArray,                                        UShort attribArraySize,                                        const char *theTag,                                        TypeException &e){    NetworkMessage req, rep ;    req.type = NetworkMessage::NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArraySize = attribArraySize ;    for (int i = 0 ; i < attribArraySize ; i++)        req.handleArray[i] = attribArray[i] ;    strcpy(req.label, theTag);    D.Out(pdDebug, "NEGOTIATED_DIVESTITURE Federate %u ", fm->federate);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE,                      req.federate);    e = rep.exception ;}// ----------------------------------------------------------------------------//! cancelNnegotiatedAttributeOwnershipDivestiture.voidOwnershipManagement::cancelnegotiatedAttributeOwnershipDivestiture(ObjectHandle theObject,                                              AttributeHandle *attribArray,                                              UShort attribArraySize,                                              TypeException &e){    NetworkMessage req, rep ;    req.type = NetworkMessage::CANCEL_NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArraySize = attribArraySize ;    for (int i = 0 ; i < attribArraySize ; i++)        req.handleArray[i] = attribArray[i] ;    D.Out(pdDebug, "CANCEL_NEGOTIATED_DIVESTITURE Federate %u ",          fm->federate);    comm->sendMessage(&req);    comm->waitMessage(&rep,                      NetworkMessage::CANCEL_NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE,                      req.federate);    e = rep.exception ;}// ----------------------------------------------------------------------------//! attributeOwnershipAcquisitionIfAvailable.voidOwnershipManagement::attributeOwnershipAcquisitionIfAvailable(ObjectHandle theObject,                                         AttributeHandle *attribArray,                                         UShort attribArraySize,                                         TypeException &e){    NetworkMessage req, rep ;    req.type = NetworkMessage::ATTRIBUTE_OWNERSHIP_ACQUISITION_IF_AVAILABLE ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArraySize = attribArraySize ;    for (int i = 0 ; i < attribArraySize ; i++)        req.handleArray[i] = attribArray[i] ;    D.Out(pdDebug, "AcquisitionIfAvailable Federate %u ", fm->federate);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::ATTRIBUTE_OWNERSHIP_ACQUISITION_IF_AVAILABLE,                      req.federate);    e = rep.exception ;}// ----------------------------------------------------------------------------//! unconditionalAttributeOwnershipDivestiture.voidOwnershipManagement::unconditionalAttributeOwnershipDivestiture(ObjectHandle theObject,                                           AttributeHandle *attribArray,                                           UShort attribArraySize,                                           TypeException &e){    NetworkMessage req, rep ;    req.type = NetworkMessage::UNCONDITIONAL_ATTRIBUTE_OWNERSHIP_DIVESTITURE ;    req.federation = fm->_numero_federation ;    req.federate = fm->federate ;    req.object = theObject ;    req.handleArraySize = attribArraySize ;    for (int i = 0 ; i < attribArraySize ; i++)        req.handleArray[i] = attribArray[i] ;    D.Out(pdDebug, "UNCONDITIONAL_DIVESTITURE Federate %u ",          fm->federate);    comm->sendMessage(&req);    comm->waitMessage(&rep, NetworkMessage::UNCONDITIONAL_ATTRIBUTE_OWNERSHIP_DIVESTITURE,                      req.federate);    e = rep.exception ;}// ----------------------------------------------------------------------------//! attributeOwnershipAcquisition.voidOwnershipManagement::attributeOwnershipAcquisition(ObjectHandle theObject,                              AttributeHandle *attribArray,                              UShort attribArraySize,                              const char *theTag,                              TypeException &e)

⌨️ 快捷键说明

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