ObjectManagement.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002-2006  ONERA
00004 //
00005 // This file is part of CERTI
00006 //
00007 // CERTI is free software ; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation ; either version 2 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // CERTI is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 //
00021 // ----------------------------------------------------------------------------
00022 
00023 #include <config.h>
00024 #include <cassert>
00025 #include <memory>
00026 
00027 #include "InteractionSet.hh"
00028 #include "ObjectSet.hh"
00029 #include "ObjectClassSet.hh"
00030 #include "ObjectManagement.hh"
00031 #include "FederationManagement.hh"
00032 #include "PrettyDebug.hh"
00033 #include "TimeManagement.hh"
00034 #include "NM_Classes.hh"
00035 
00036 #ifdef _WIN32
00037 #include <windows.h>
00038 #else
00039 #include <sys/types.h>
00040 #include <sys/stat.h>
00041 #include <unistd.h>
00042 #include <stdlib.h>
00043 #include <iostream>
00044 #endif
00045 using std::cout ;
00046 using std::endl ;
00047 using std::string ;
00048 
00049 namespace certi {
00050 namespace rtia {
00051 
00052 static PrettyDebug D("RTIA_OM", __FILE__);
00053 static PrettyDebug G("GENDOC",__FILE__);
00054 
00055 const ObjectManagement::TransportTypeList
00056 ObjectManagement::transportTypeList[] = {
00057     { "HLAreliable", RELIABLE },
00058     { "HLAbestEffort", BEST_EFFORT },
00059     { NULL }
00060 };
00061 
00062 const ObjectManagement::OrderTypeList
00063 ObjectManagement::orderTypeList[] = {
00064     { "Receive", RECEIVE },
00065     { "Timestamp", TIMESTAMP },
00066     { NULL }
00067 };
00068 
00069 ObjectManagement::ObjectManagement(Communications *GC,
00070                                    FederationManagement *GF,
00071                                    RootObject *theRootObj)
00072     : comm(GC),
00073       fm(GF),
00074       rootObject(theRootObj) { }
00075 
00076 ObjectManagement::~ObjectManagement() { }
00077 
00078 
00079 // ----------------------------------------------------------------------------
00081 ObjectHandle
00082 ObjectManagement::registerObject(ObjectClassHandle the_class,
00083                                  const char *theObjectName,
00084                                  FederationTime,
00085                                  FederationTime,
00086                                  TypeException & e)
00087 {
00088     NM_Register_Object req;
00089 
00090     req.federate    = fm->federate ;
00091     req.federation  = fm->_numero_federation ;
00092     req.objectClass = the_class ;
00093     req.setLabel(theObjectName);
00094 
00095     comm->sendMessage(&req);
00096 
00097     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::REGISTER_OBJECT, req.federate));
00098 
00099     e = rep->exception ;
00100 
00101     if (e == e_NO_EXCEPTION) {
00102         rootObject->registerObjectInstance(fm->federate, the_class, rep->object,
00103                                            rep->getLabel().c_str());
00104         return rep->object ;
00105     }
00106     else {
00107         return 0;
00108     }
00109 }
00110 
00111 // ----------------------------------------------------------------------------
00113 
00122 EventRetractionHandle
00123 ObjectManagement::updateAttributeValues(ObjectHandle theObjectHandle,
00124                                         std::vector<AttributeHandle> &attribArray,
00125                                         std::vector<AttributeValue_t> &valueArray,
00126                                         UShort attribArraySize,
00127                                         FederationTime theTime,
00128                                         std::string theTag,
00129                                         TypeException &e)
00130 {
00131     NM_Update_Attribute_Values req;
00132     int i ;
00133     bool validCall ;
00134     EventRetractionHandle evtrHandle;
00135 
00136     G.Out(pdGendoc,"enter ObjectManagement::updateAttributeValues with time");
00137     validCall = tm->testValidTime(theTime) ;
00138     if (validCall) {
00139 
00140         // Building request (req NetworkMessage)
00141         req.federation = fm->_numero_federation ;
00142         req.federate = fm->federate ;
00143         req.object = theObjectHandle ;
00144         // set Date for UAV with time
00145         req.setDate(theTime);
00146         req.handleArray.resize(attribArraySize) ;
00147         req.handleArraySize = attribArraySize ;
00148         req.sizeValueArray(attribArraySize) ;
00149 
00150         for (i = 0 ; i < attribArraySize ; i++) {
00151             req.handleArray[i] = attribArray[i] ;
00152             req.valueArray[i] = valueArray[i] ;
00153         }
00154 
00155         req.setLabel(theTag);
00156 
00157         comm->sendMessage(&req);
00158         std::auto_ptr<NetworkMessage> rep(comm->waitMessage(req.getType(), req.federate));
00159         e = rep->exception ;
00160         evtrHandle = rep->eventRetraction;
00161     }
00162     else {
00163        std::stringstream errorMsg;
00164        errorMsg << "UAV InvalidFederationTime: "<<std::endl;
00165        errorMsg << " providedTime =" << theTime<<std::endl;
00166        errorMsg << " currentTime  =" << tm->requestFederateTime()<<std::endl;
00167        errorMsg << " lookahead    =" << tm->requestLookahead()<<std::endl;
00168 
00169        D.Out(pdDebug,errorMsg.str().c_str());
00170        e = e_InvalidFederationTime;
00171     }
00172 
00173     // FIXME returned evtrHandle carry uninitialized value
00174     G.Out(pdGendoc,"exit ObjectManagement::updateAttributeValues with time");
00175     return evtrHandle ;
00176 }
00177 
00178 // ----------------------------------------------------------------------------
00180 
00188 void
00189 ObjectManagement::updateAttributeValues(ObjectHandle theObjectHandle,
00190                                         std::vector<AttributeHandle> &attribArray,
00191                                         std::vector<AttributeValue_t> &valueArray,
00192                                         UShort attribArraySize,
00193                                         std::string theTag,
00194                                         TypeException &e)
00195 {
00196     NM_Update_Attribute_Values req;
00197     int i ;
00198 
00199     G.Out(pdGendoc,"enter ObjectManagement::updateAttributeValues without time");
00200     // Building request (req NetworkMessage)
00201     req.federation = fm->_numero_federation ;
00202     req.federate = fm->federate ;
00203     req.object = theObjectHandle ;
00204     // Do no set Date if without time
00205     req.handleArray.resize(attribArraySize) ;
00206     req.handleArraySize = attribArraySize ;
00207     req.sizeValueArray(attribArraySize) ;
00208 
00209     for (i = 0 ; i < attribArraySize ; i++) {
00210         req.handleArray[i] = attribArray[i] ;
00211         req.valueArray[i] = valueArray[i];
00212     }
00213 
00214     req.setLabel(theTag);
00215 
00216     comm->sendMessage(&req);
00217     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(req.getType(), req.federate));
00218 
00219     e = rep->exception ;
00220     G.Out(pdGendoc,"exit  ObjectManagement::updateAttributeValues without time");
00221 }
00222 
00223 // ----------------------------------------------------------------------------
00225 void
00226 ObjectManagement::discoverObject(ObjectHandle the_object,
00227                                  ObjectClassHandle the_class,
00228                                  const char *the_name,
00229                                  FederationTime the_time,
00230                                  EventRetractionHandle the_event,
00231                                  TypeException &)
00232 {
00233     Message req;
00234 
00235     req.type = Message::DISCOVER_OBJECT_INSTANCE ;
00236     req.setObject(the_object);
00237     req.setObjectClass(the_class);
00238     req.setFederationTime(the_time);
00239     req.setEventRetraction(the_event);
00240     req.setName(the_name);
00241 
00242     comm->requestFederateService(&req);
00243 
00244     /* FIXME
00245      *
00246      * discoverObject tries to auto-registrate a discovered object instance,
00247      * if the object is already discovered through a previous invocation of
00248      * discoverObject the exceptiobn ObjectAlreadyRegistered is raised.
00249      *
00250      * This behaviour needs further investigation. 
00251      * Is it useful to call registerObjectInstance within a federate service?
00252      */
00253 
00254     try {
00255       // Adding discovered object in federate internal object list.
00256       rootObject->registerObjectInstance(fm->federate, the_class, the_object,
00257                                          req.getName().c_str());
00258     } 
00259     catch (ObjectAlreadyRegistered) {
00260     }
00261 }
00262 
00263 // ----------------------------------------------------------------------------
00265 void
00266 ObjectManagement::reflectAttributeValues(ObjectHandle the_object,
00267                                          std::vector <AttributeHandle> &the_attributes,
00268                                          std::vector <AttributeValue_t> &the_values,
00269                                          UShort the_size,
00270                                          FederationTime the_time,
00271                                          const char *the_tag,
00272                                          EventRetractionHandle the_event,
00273                                          TypeException &)
00274 {
00275     Message req;
00276 
00277     G.Out(pdGendoc,"enter ObjectManagement::reflectAttributeValues with time");
00278     req.type = Message::REFLECT_ATTRIBUTE_VALUES ;
00279     req.setObject(the_object);
00280     req.setFederationTime(the_time);
00281     req.setEventRetraction(the_event);
00282     req.setTag(the_tag);
00283     req.setAttributes(the_attributes, the_values, the_size);
00284     // true for RAV without time
00285     req.setBoolean(true);
00286 
00287     comm->requestFederateService(&req);
00288     G.Out(pdGendoc,"exit  ObjectManagement::reflectAttributeValues with time");
00289 }
00290 
00291 // ----------------------------------------------------------------------------
00293 void
00294 ObjectManagement::reflectAttributeValues(ObjectHandle the_object,
00295                                          std::vector <AttributeHandle> &the_attributes,
00296                                          std::vector <AttributeValue_t> &the_values,
00297                                          UShort the_size,
00298                                          const char *the_tag,
00299                                          TypeException &)
00300 {
00301     Message req;
00302 
00303     G.Out(pdGendoc,"enter ObjectManagement::reflectAttributeValues without time");
00304     req.type = Message::REFLECT_ATTRIBUTE_VALUES ;
00305     req.setObject(the_object);
00306     req.setTag(the_tag);
00307     req.setAttributes(the_attributes, the_values, the_size);
00308     // false for RAV without time
00309     req.setBoolean(false);
00310 
00311     comm->requestFederateService(&req);
00312     G.Out(pdGendoc,"exit  ObjectManagement::reflectAttributeValues without time");
00313 }
00314 
00315 // ----------------------------------------------------------------------------
00317 EventRetractionHandle
00318 ObjectManagement::sendInteraction(InteractionClassHandle theInteraction,
00319                                   std::vector <ParameterHandle> &paramArray,
00320                                   std::vector <ParameterValue_t> &valueArray,
00321                                   UShort paramArraySize,
00322                                   FederationTime theTime,
00323                                   std::string theTag,
00324                   RegionHandle region,
00325                                   TypeException &e)
00326 {
00327     NM_Send_Interaction req;
00328     bool validCall ;
00329     EventRetractionHandle evtrHandle;
00330 
00331     validCall = tm->testValidTime(theTime) ;
00332     if (validCall) {
00333 
00334        G.Out(pdGendoc,"ObjectManagement::sendInteraction with time") ;
00335        // Local test to know if interaction is correct.
00336        rootObject->Interactions->isReady(fm->federate,
00337                                          theInteraction,
00338                                          paramArray,
00339                                          paramArraySize);
00340 
00341        // Building network message (req) to RTIG.
00342        req.interactionClass = theInteraction ;
00343        // true for UAV with time
00344        req.setDate(theTime);
00345        req.region = region ;
00346        req.federation = fm->_numero_federation ;
00347        req.federate = fm->federate ;
00348        req.handleArray.resize(paramArraySize) ;
00349        req.handleArraySize = paramArraySize ;
00350        req.sizeValueArray(paramArraySize) ;
00351 
00352        for (int i=0 ; i<paramArraySize ; i++) {
00353             req.handleArray[i] = paramArray[i] ;
00354                 req.valueArray[i] = valueArray[i];
00355        }
00356 
00357        req.setLabel(theTag);
00358 
00359        // Send network message and then wait for answer.
00360        comm->sendMessage(&req);
00361        std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::SEND_INTERACTION, req.federate));
00362        e = rep->exception ;
00363        evtrHandle = rep->eventRetraction;
00364     }
00365     else {
00366        e = e_InvalidFederationTime ;
00367     }
00368 
00369     // FIXME returned evtrHandle carry uninitialized value
00370     return evtrHandle ;
00371 }
00372 
00373 // ----------------------------------------------------------------------------
00375 void
00376 ObjectManagement::sendInteraction(InteractionClassHandle theInteraction,
00377                                   std::vector <ParameterHandle> &paramArray,
00378                                   std::vector <ParameterValue_t> &valueArray,
00379                                   UShort paramArraySize,
00380                                   std::string theTag,
00381                   RegionHandle region,
00382                                   TypeException &e)
00383 {
00384     NM_Send_Interaction req;
00385     G.Out(pdGendoc,"ObjectManagement::sendInteraction without time");
00386     // Local test to know if interaction is correct.
00387     rootObject->Interactions->isReady(fm->federate,
00388                                       theInteraction,
00389                                       paramArray,
00390                                       paramArraySize);
00391 
00392     // Building network message (req) to RTIG.
00393     req.interactionClass = theInteraction ;
00394     req.region     = region ;
00395     req.federation = fm->_numero_federation ;
00396     req.federate   = fm->federate ;
00397     req.handleArray.resize(paramArraySize) ;
00398     req.handleArraySize = paramArraySize ;
00399     req.sizeValueArray(paramArraySize) ;
00400 
00401     for (int i=0 ; i<paramArraySize ; i++) {
00402             req.handleArray[i] = paramArray[i] ;
00403                 req.valueArray[i] = valueArray[i];
00404     }
00405 
00406     req.setLabel(theTag);
00407 
00408     // Send network message and then wait for answer.
00409     comm->sendMessage(&req);
00410     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::SEND_INTERACTION, req.federate));
00411 
00412     e = rep->exception ;
00413 
00414 } /* end of sendInteraction */
00415 
00416 // ----------------------------------------------------------------------------
00418 void
00419 ObjectManagement::receiveInteraction(InteractionClassHandle the_interaction,
00420                                      std::vector <ParameterHandle> &the_parameters,
00421                                      std::vector <ParameterValue_t> &the_values,
00422                                      UShort the_size,
00423                                      FederationTime the_time,
00424                                      const char *the_tag,
00425                                      EventRetractionHandle the_event,
00426                                      TypeException &)
00427 {
00428     Message req;
00429 
00430     req.type = Message::RECEIVE_INTERACTION ;
00431     req.setInteractionClass(the_interaction);
00432     req.setFederationTime(the_time);
00433     req.setEventRetraction(the_event);
00434     req.setTag(the_tag);
00435     req.setParameters(the_parameters, the_values, the_size);
00436     req.setBoolean(true);
00437     comm->requestFederateService(&req);
00438 }
00439 
00440 // ----------------------------------------------------------------------------
00442 void
00443 ObjectManagement::receiveInteraction(InteractionClassHandle the_interaction,
00444                                      std::vector <ParameterHandle> &the_parameters,
00445                                      std::vector <ParameterValue_t> &the_values,
00446                                      UShort the_size,
00447                                      const char *the_tag,
00448                                      TypeException &)
00449 {
00450     Message req;
00451 
00452     req.type = Message::RECEIVE_INTERACTION ;
00453     req.setInteractionClass(the_interaction);
00454     req.setTag(the_tag);
00455     req.setParameters(the_parameters, the_values, the_size);
00456     req.setBoolean(false);
00457     comm->requestFederateService(&req);
00458 }
00459 
00460 // ----------------------------------------------------------------------------
00462 EventRetractionHandle
00463 ObjectManagement::deleteObject(ObjectHandle theObjectHandle,
00464                    FederationTime theTime,
00465                                std::string theTag,
00466                                TypeException &e)
00467 {
00468     NM_Delete_Object req;
00469 
00470     req.object     = theObjectHandle ;
00471     req.setDate(theTime);
00472     req.federation = fm->_numero_federation ;
00473     req.federate   = fm->federate ;
00474 
00475     req.setLabel(theTag);
00476     comm->sendMessage(&req);
00477     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::DELETE_OBJECT, req.federate));
00478 
00479     e = rep->exception ;
00480 
00481     if (e == e_NO_EXCEPTION) {
00482         rootObject->deleteObjectInstance(fm->federate, theObjectHandle, theTag);
00483     }
00484 
00485     return rep->eventRetraction ;
00486 } /* end deleteObject */
00487 
00488 // ----------------------------------------------------------------------------
00490 void
00491 ObjectManagement::deleteObject(ObjectHandle theObjectHandle,
00492                                std::string theTag,
00493                                TypeException &e)
00494 {
00495     NM_Delete_Object req;
00496 
00497     req.object     = theObjectHandle ;
00498     req.federation = fm->_numero_federation ;
00499     req.federate   = fm->federate ;
00500 
00501     req.setLabel(theTag);
00502     comm->sendMessage(&req);
00503     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::DELETE_OBJECT, req.federate));
00504 
00505     e = rep->exception ;
00506 
00507     if (e == e_NO_EXCEPTION) {
00508         rootObject->deleteObjectInstance(fm->federate, theObjectHandle, theTag);
00509     }
00510 } /* end of deleteObject */
00511 
00512 // ----------------------------------------------------------------------------
00514 void
00515 ObjectManagement::removeObject(ObjectHandle the_object,
00516                                FederateHandle the_federate,
00517                                FederationTime theTime,
00518                                const char *the_tag,
00519                                EventRetractionHandle the_event,
00520                                TypeException &)
00521 
00522 {
00523     Message req;
00524 
00525     req.type = Message::REMOVE_OBJECT_INSTANCE ;
00526     req.setObject(the_object);
00527     req.setEventRetraction(the_event);
00528     req.setTag(the_tag);
00529     req.setFederationTime(theTime);
00530     req.setBoolean(true);
00531 
00532     comm->requestFederateService(&req);
00533 
00534     rootObject->deleteObjectInstance(the_federate, the_object, theTime, the_tag);
00535 }
00536 
00537 // ----------------------------------------------------------------------------
00539 void
00540 ObjectManagement::removeObject(ObjectHandle the_object,
00541                                FederateHandle the_federate,
00542                                const char *the_tag,
00543                                TypeException &)
00544 {
00545     Message req;
00546 
00547     req.type = Message::REMOVE_OBJECT_INSTANCE ;
00548     req.setObject(the_object);
00549     req.setTag(the_tag);
00550     req.setBoolean(false);
00551 
00552     comm->requestFederateService(&req);
00553 
00554     rootObject->deleteObjectInstance(the_federate, the_object, the_tag);
00555 }
00556 
00557 // ----------------------------------------------------------------------------
00559 EventRetractionHandle
00560 ObjectManagement::changeAttributeTransportType(ObjectHandle theObjectHandle,
00561                                                std::vector <AttributeHandle> &attribArray,
00562                                                UShort attribArraySize,
00563                                                TransportType theType,
00564                                                TypeException &e)
00565 {
00566     NM_Change_Attribute_Transport_Type req;
00567     int i ;
00568 
00569     req.object = theObjectHandle ;
00570     req.federation = fm->_numero_federation ;
00571     req.federate = fm->federate ;
00572     req.transport = theType ;
00573     req.handleArray.resize(attribArraySize) ;
00574 
00575     for (i = 0 ; i < attribArraySize ; i++)
00576         req.handleArray[i] = attribArray[i] ;
00577 
00578     comm->sendMessage(&req);
00579 
00580     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(
00581                       NetworkMessage::CHANGE_ATTRIBUTE_TRANSPORT_TYPE,
00582                       req.federate));
00583 
00584     e = rep->exception ;
00585 
00586     return rep->eventRetraction ;
00587 }
00588 
00589 // ----------------------------------------------------------------------------
00591 EventRetractionHandle
00592 ObjectManagement::changeAttributeOrderType(ObjectHandle theObjectHandle,
00593                                            std::vector <AttributeHandle> &attribArray,
00594                                            UShort attribArraySize,
00595                                            OrderType theType,
00596                                            TypeException &e)
00597 {
00598     NM_Change_Attribute_Order_Type req ;
00599     int i ;
00600 
00601     req.object = theObjectHandle ;
00602     req.federation = fm->_numero_federation ;
00603     req.federate = fm->federate ;
00604     req.order = theType ;
00605     req.handleArraySize = attribArraySize ;
00606     req.handleArray.resize(attribArraySize) ;
00607 
00608     for (i = 0 ; i < attribArraySize ; i++)
00609         req.handleArray[i] = attribArray[i] ;
00610 
00611 
00612     comm->sendMessage(&req);
00613 
00614     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::CHANGE_ATTRIBUTE_ORDER_TYPE, req.federate));
00615 
00616     e = rep->exception ;
00617 
00618     return rep->eventRetraction ;
00619 }
00620 
00621 // ----------------------------------------------------------------------------
00623 EventRetractionHandle
00624 ObjectManagement::changeInteractionTransportType(InteractionClassHandle id,
00625                                                  TransportType theType,
00626                                                  TypeException &e)
00627 {
00628     NM_Change_Interaction_Transport_Type req;
00629 
00630     req.interactionClass = id ;
00631     req.federation = fm->_numero_federation ;
00632     req.federate = fm->federate ;
00633     req.transport = theType ;
00634 
00635     comm->sendMessage(&req);
00636     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::CHANGE_INTERACTION_TRANSPORT_TYPE, req.federate));
00637     e = rep->exception ;
00638 
00639     return rep->eventRetraction ;
00640 }
00641 
00642 // ----------------------------------------------------------------------------
00644 EventRetractionHandle
00645 ObjectManagement::changeInteractionOrderType(InteractionClassHandle id,
00646                                              OrderType theType,
00647                                              TypeException &e)
00648 {
00649     NM_Change_Interaction_Order_Type req;
00650 
00651     req.interactionClass = id ;
00652     req.federation = fm->_numero_federation ;
00653     req.federate = fm->federate ;
00654     req.order = theType ;
00655 
00656     comm->sendMessage(&req);
00657 
00658     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::CHANGE_INTERACTION_ORDER_TYPE, req.federate));
00659 
00660     e = rep->exception ;
00661 
00662     return rep->eventRetraction ;
00663 } /* end of changeInteractionOrderType */
00664 
00665 // ----------------------------------------------------------------------------
00667 void
00668 ObjectManagement::requestObjectAttributeValueUpdate(ObjectHandle handle,
00669                                                     std::vector <AttributeHandle> &attribs,
00670                                                     UShort attribArraySize,
00671                                                     TypeException &e)
00672 {
00673     NM_Request_Object_Attribute_Value_Update req;
00674 
00675     G.Out(pdGendoc,"enter ObjectManagement::requestObjectAttributeValueUpdate");
00676 
00677     req.object = handle ;
00678     req.federation = fm->_numero_federation ;
00679     req.federate = fm->federate ;
00680     req.handleArray.resize(attribArraySize) ;
00681 
00682     for (int i = 0 ; i < attribArraySize ; i++) {
00683         req.handleArray[i] = attribs[i] ;
00684     }
00685 
00686     req.handleArraySize = attribArraySize ;
00687     comm->sendMessage(&req);
00688     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(NetworkMessage::REQUEST_OBJECT_ATTRIBUTE_VALUE_UPDATE,
00689                       req.federate));
00690     e = rep->exception ;
00691     G.Out(pdGendoc,"exit  ObjectManagement::requestObjectAttributeValueUpdate");
00692 
00693 } /* end of requestObjectAttributeValueUpdate */
00694 
00695 
00696 // --------------------------------------
00697 // -- 4.15 provideAttributeValueUpdate --
00698 // --------------------------------------
00699 
00700 void
00701 ObjectManagement::provideAttributeValueUpdate(ObjectHandle the_object,
00702                                               std::vector <AttributeHandle> &the_attributes,
00703                                               UShort attribArraySize,
00704                                               TypeException &)
00705 {
00706     Message req;
00707 
00708     G.Out(pdGendoc,"enter ObjectManagement::provideAttributeValueUpdate");
00709     req.type = Message::PROVIDE_ATTRIBUTE_VALUE_UPDATE ;
00710     req.setObject(the_object);
00711     req.handleArraySize = attribArraySize ;
00712     req.handleArray.resize(req.handleArraySize) ;
00713     for (int i = 0 ; i < attribArraySize ; i++) {
00714         req.handleArray[i] = the_attributes[i] ;
00715     }
00716 
00717     comm->requestFederateService(&req);
00718     G.Out(pdGendoc,"exit  ObjectManagement::provideAttributeValueUpdate");
00719 }
00720 
00721 // ------------------
00722 // -- 4.16 retract --
00723 // ------------------
00724 
00725 void ObjectManagement::retract(EventRetractionHandle /*theHandle*/,
00726                                TypeException & /*e*/)
00727 {
00728     throw RTIinternalError("ObjectManagement::retract not implemented.");
00729 }
00730 
00731 
00732 // ----------------------------
00733 // -- 4.17 reflectRetraction --
00734 // ----------------------------
00735 
00736 void
00737 ObjectManagement::reflectRetraction(EventRetractionHandle,
00738                                     TypeException &)
00739 {
00740     throw RTIinternalError("ObjectManagement::reflectRetraction not implemented.");
00741 }
00742 
00743 // ----------------------------------------------------------------------------
00745 ObjectClassHandle
00746 ObjectManagement::getObjectClassHandle(const char *theName)
00747 {
00748     ObjectClassHandle handle ;
00749     G.Out(pdGendoc,"enter ObjectManagement::getObjectClassHandle");
00750     try {
00751          handle = rootObject->ObjectClasses->getObjectClassHandle(theName);
00752          G.Out(pdGendoc,"exit  ObjectManagement::getObjectClassHandle");
00753          return handle;
00754          }
00755     catch (NameNotFound) {
00756          G.Out(pdGendoc,"exit  ObjectManagement::getObjectClassHandle on NameNotFound");
00757          throw NameNotFound(theName);
00758          }
00759 }
00760 
00761 
00762 // ----------------------------------------------------------------------------
00764 string
00765 ObjectManagement::getObjectClassName(ObjectClassHandle theHandle)
00766 {
00767     return rootObject->ObjectClasses->getObjectClassName(theHandle);
00768 }
00769 
00770 // ----------------------------------------------------------------------------
00772 ObjectHandle
00773 ObjectManagement::getObjectInstanceHandle(const char *the_name)
00774 {
00775     return rootObject->objects->getObjectInstanceHandle(the_name);
00776 }
00777 
00778 // ----------------------------------------------------------------------------
00780 const char *
00781 ObjectManagement::getObjectInstanceName(ObjectHandle the_object)
00782 {
00783     return rootObject->objects->getObjectInstanceName(the_object);
00784 }
00785 
00786 // ----------------------------------------------------------------------------
00788 AttributeHandle
00789 ObjectManagement::getAttributeHandle(const char *theName,
00790                                      ObjectClassHandle theClassHandle)
00791 {
00792     AttributeHandle handle ;
00793     G.Out(pdGendoc,"enter ObjectManagement::getAttributeHandle");
00794     try {
00795         handle = rootObject->ObjectClasses->getAttributeHandle(theName,
00796                                                          theClassHandle);
00797         G.Out(pdGendoc,"exit  ObjectManagement::getAttributeHandle");
00798         return handle;
00799         }
00800      catch (NameNotFound) {
00801          G.Out(pdGendoc,"exit  ObjectManagement::getAttributeHandle on NameNotFound");
00802          throw NameNotFound(theName);
00803         }
00804 }
00805 
00806 // ----------------------------------------------------------------------------
00808 const char *
00809 ObjectManagement::getAttributeName(AttributeHandle theHandle,
00810                                    ObjectClassHandle theClassHandle)
00811 {
00812     return rootObject->ObjectClasses->getAttributeName(theHandle,
00813                                                        theClassHandle);
00814 }
00815 
00816 // ----------------------------------------------------------------------------
00818 InteractionClassHandle
00819 ObjectManagement::getInteractionClassHandle(const char *theName)
00820 {
00821     return rootObject->Interactions->getInteractionClassHandle(theName);
00822 }
00823 
00824 // ----------------------------------------------------------------------------
00826 const std::string
00827 ObjectManagement::
00828 getInteractionClassName(InteractionClassHandle theClassHandle)
00829 {
00830     return
00831         rootObject->Interactions->getInteractionClassName(theClassHandle);
00832 }
00833 
00834 // ----------------------------------------------------------------------------
00836 ParameterHandle
00837 ObjectManagement::getParameterHandle(const char *theParameterName,
00838                                      InteractionClassHandle theClassHandle)
00839 {
00840     return rootObject->Interactions->getParameterHandle(theParameterName,
00841                                                         theClassHandle);
00842 }
00843 
00844 // ----------------------------------------------------------------------------
00846 const std::string&
00847 ObjectManagement::getParameterName(ParameterHandle theParameterHandle,
00848                                    InteractionClassHandle theClassHandle)
00849 {
00850     return rootObject->Interactions->getParameterName(theParameterHandle,
00851                                                       theClassHandle);
00852 }
00853 
00854 // ----------------------------------------------------------------------------
00856 ObjectClassHandle
00857 ObjectManagement::getObjectClass(ObjectHandle object)
00858 {
00859     return rootObject->objects->getObjectClass(object);
00860 }
00861 
00862 // ----------------------------------------------------------------------------
00864 TransportType
00865 ObjectManagement::getTransportationHandle(const char *theName)
00866 {
00867     for(const TransportTypeList *item = transportTypeList; item->name != NULL; item++) {
00868         if(strcmp(theName, item->name) == 0)
00869             return item->type;
00870     }
00871 
00872     throw NameNotFound(theName);
00873 }
00874 
00875 // ----------------------------------------------------------------------------
00877 const char *
00878 ObjectManagement::getTransportationName(TransportType theType)
00879 {
00880     for(const TransportTypeList *item = transportTypeList; item->name != NULL; item++) {
00881         if(theType == item->type)
00882             return item->name;
00883     }
00884 
00885     throw InvalidTransportationHandle("");
00886 }
00887 
00888 // ----------------------------------------------------------------------------
00890 OrderType
00891 ObjectManagement::getOrderingHandle(const char *theName)
00892 {
00893     for(const OrderTypeList *item = orderTypeList; item->name != NULL; item++) {
00894         if(strcmp(theName, item->name) == 0)
00895             return item->type;
00896     }
00897 
00898     throw NameNotFound(theName);
00899 }
00900 
00901 // ----------------------------------------------------------------------------
00903 const char *
00904 ObjectManagement::getOrderingName(OrderType theType)
00905 {
00906     for(const OrderTypeList *item = orderTypeList; item->name != NULL; item++) {
00907         if(theType == item->type)
00908             return item->name;
00909     }
00910 
00911     throw InvalidOrderingHandle("");
00912 }
00913 
00914 void
00915 ObjectManagement::
00916 setAttributeScopeAdvisorySwitch(bool state, TypeException &e) {
00917     G.Out(pdGendoc,"enter ObjectManagement::setAttributeScopeAdvisorySwitch");
00918 
00919     NM_Set_Attribute_Scope_Advisory_Switch msg ;
00920 
00921     e = e_NO_EXCEPTION ;
00922 
00923     msg.federation = fm->_numero_federation ;
00924     msg.federate = fm->federate ;
00925 
00926     if (state) {
00927         msg.attributeScopeAdvisorySwitchOn();
00928     }
00929     else {
00930         msg.attributeScopeAdvisorySwitchOff();
00931     }
00932 
00933     comm->sendMessage(&msg);
00934 
00935     G.Out(pdGendoc,"exit ObjectManagement::setAttributeScopeAdvisorySwitch");
00936 }
00937 
00938 // --------------------------------------
00939 // -- 6.13 attributesInScope
00940 // --------------------------------------
00941 void
00942 ObjectManagement::
00943 attributesInScope(ObjectHandle theObject,
00944                   const std::vector <AttributeHandle> &attribArray,
00945                   const UShort attribArraySize,
00946                   TypeException &e) {
00947     Message req;
00948 
00949     G.Out(pdGendoc,"enter ObjectManagement::attributesInScope");
00950 
00951     req.type = Message::ATTRIBUTES_IN_SCOPE;
00952     req.setObject(theObject);
00953     req.handleArraySize = attribArraySize;
00954     req.handleArray.resize(attribArraySize);
00955 
00956     for (int i = 0 ; i < attribArraySize ; i++)
00957         req.handleArray[i] = attribArray[i];
00958 
00959     comm->requestFederateService(&req);
00960 
00961     G.Out(pdGendoc,"exit  ObjectManagement::attributesInScope");
00962 }
00963 
00964 // --------------------------------------
00965 // -- 6.14 attributesOutOfScope
00966 // --------------------------------------
00967 
00968 void
00969 ObjectManagement::
00970 attributesOutOfScope(ObjectHandle theObject,
00971                      const std::vector <AttributeHandle> &attribArray,
00972                      const UShort attribArraySize,
00973                      TypeException &e) {
00974     Message req;
00975 
00976     G.Out(pdGendoc,"enter ObjectManagement::attributesOutScope");
00977 
00978     req.type = Message::ATTRIBUTES_OUT_OF_SCOPE;
00979     req.setObject(theObject);
00980     req.handleArraySize = attribArraySize;
00981     req.handleArray.resize(attribArraySize);
00982 
00983     for (int i = 0 ; i < attribArraySize ; i++)
00984         req.handleArray[i] = attribArray[i];
00985 
00986     comm->requestFederateService(&req);
00987 
00988     G.Out(pdGendoc,"exit  ObjectManagement::attributesOutScope");
00989 }
00990 
00991 void
00992 ObjectManagement::
00993 setAttributeRelevanceAdvisorySwitch(bool state, TypeException &e) {
00994     G.Out(pdGendoc,"enter ObjectManagement::setAttributeRelevanceAdvisorySwitch");
00995 
00996     NM_Set_Attribute_Relevance_Advisory_Switch msg ;
00997 
00998     e = e_NO_EXCEPTION ;
00999 
01000     msg.federation = fm->_numero_federation ;
01001     msg.federate = fm->federate ;
01002 
01003     if (state) {
01004         msg.attributeRelevanceAdvisorySwitchOn();
01005     }
01006     else {
01007         msg.attributeRelevanceAdvisorySwitchOff();
01008     }
01009 
01010     comm->sendMessage(&msg);
01011 
01012     G.Out(pdGendoc,"exit ObjectManagement::setAttributeRelevanceAdvisorySwitch");
01013 }
01014 
01015 // --------------------------------------
01016 // -- 6.17 turnUpdatesOnForObjectInstance
01017 // --------------------------------------
01018 
01019 void
01020 ObjectManagement::
01021 turnUpdatesOnForObjectInstance(ObjectHandle theObject,
01022                            const std::vector <AttributeHandle> &attribArray,
01023                            const UShort attribArraySize,
01024                            TypeException &e) {
01025     Message req;
01026 
01027     G.Out(pdGendoc,"enter ObjectManagement::turnUpdatesOnForObjectInstance");
01028 
01029     req.type = Message::TURN_UPDATES_ON_FOR_OBJECT_INSTANCE;
01030     req.setObject(theObject);
01031     req.handleArraySize = attribArraySize;
01032     req.handleArray.resize(attribArraySize);
01033 
01034     for (int i = 0 ; i < attribArraySize ; i++)
01035         req.handleArray[i] = attribArray[i];
01036 
01037     comm->requestFederateService(&req);
01038 
01039     G.Out(pdGendoc,"exit  ObjectManagement::turnUpdatesOnForObjectInstance");
01040 }
01041 
01042 // --------------------------------------
01043 // -- 6.18 turnUpdatesOffForObjectInstance
01044 // --------------------------------------
01045 
01046 void
01047 ObjectManagement::
01048 turnUpdatesOffForObjectInstance(ObjectHandle theObject,
01049                          const std::vector <AttributeHandle> &attribArray,
01050                          const UShort attribArraySize,
01051                          TypeException &e) {
01052     Message req;
01053 
01054     G.Out(pdGendoc,"enter ObjectManagement::turnUpdatesOffForObjectInstance");
01055 
01056     req.type = Message::TURN_UPDATES_OFF_FOR_OBJECT_INSTANCE;
01057     req.setObject(theObject);
01058     req.handleArraySize = attribArraySize;
01059     req.handleArray.resize(attribArraySize);
01060 
01061     for (int i = 0 ; i < attribArraySize ; i++)
01062         req.handleArray[i] = attribArray[i];
01063 
01064     comm->requestFederateService(&req);
01065 
01066     G.Out(pdGendoc,"exit  ObjectManagement::turnUpdatesOffForObjectInstance");
01067 }
01068 
01069 }} // namespace certi/rtia
01070 

Generated on Thu Apr 30 15:53:49 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5