# FederationsList.cc

Go to the documentation of this file.

    00001 // ----------------------------------------------------------------------------
    00002 // CERTI - HLA RunTime Infrastructure
    00003 // Copyright (C) 2002-2005  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 // $Id: FederationsList.cc,v 3.63 2008/12/07 20:16:11 gotthardp Exp $
    00022 // ----------------------------------------------------------------------------
    00023
    00024 #include <config.h>
    00025 #include "FederationsList.hh"
    00026
    00027 using std::list ;
    00028 using std::endl ;
    00029 using std::cout ;
    00030
    00031 namespace certi {
    00032 namespace rtig {
    00033
    00034 static PrettyDebug D("FEDERATIONSLIST", __FILE__);
    00035 static PrettyDebug G("GENDOC",__FILE__);
    00036
    00037 // ----------------------------------------------------------------------------
    00038 // Constructor
    00039 FederationsList::FederationsList(SocketServer &server, AuditFile &audit)
    00040     : list<Federation *>(),
    00041       socketServer(server),
    00042       auditFile(audit),
    00043       verboseLevel(0)
    00044 {
    00045 }
    00046
    00047 // ----------------------------------------------------------------------------
    00048 // Destructor
    00049 FederationsList::~FederationsList()
    00050 {
    00051     if (!empty())
    00052         D.Out(pdError, "ListeFederation not empty at destruction time.");
    00053
    00054     for (list<Federation *>::iterator i = begin(); i != end(); i++) {
    00055         delete(*i);
    00056     }
    00057     clear();
    00058 }
    00059
    00060 // ----------------------------------------------------------------------------
    00062 void
    00063 FederationsList::setClassRelevanceAdvisorySwitch(Handle handle,
    00064                                          FederateHandle federate)
    00065     throw (FederationExecutionDoesNotExist,
    00066            FederateNotExecutionMember,
    00067            SaveInProgress,
    00068            RestoreInProgress,
    00069            RTIinternalError)
    00070 {
    00071     Federation *federation = NULL ;
    00072
    00073     // It may throw RTIinternalError.
    00074     checkHandle(handle);
    00075     checkHandle(federate);
    00076
    00077     // It may throw FederationExecutionDoesNotExist.
    00078     searchFederation(handle, federation);
    00079
    00080     // It may throw a bunch of exceptions.
    00081     federation->setClassRelevanceAdvisorySwitch(federate);
    00082 }
    00083
    00084 // ----------------------------------------------------------------------------
    00086 void
    00087 FederationsList::unsetClassRelevanceAdvisorySwitch(Handle handle,
    00088                                          FederateHandle federate)
    00089     throw (FederationExecutionDoesNotExist,
    00090            FederateNotExecutionMember,
    00091            SaveInProgress,
    00092            RestoreInProgress,
    00093            RTIinternalError)
    00094 {
    00095     Federation *federation = NULL ;
    00096
    00097     // It may throw RTIinternalError.
    00098     checkHandle(handle);
    00099     checkHandle(federate);
    00100
    00101     // It may throw FederationExecutionDoesNotExist.
    00102     searchFederation(handle, federation);
    00103
    00104     // It may throw a bunch of exceptions.
    00105     federation->unsetClassRelevanceAdvisorySwitch(federate);
    00106 }
    00107
    00108 // ----------------------------------------------------------------------------
    00110 void
    00111 FederationsList::setInteractionRelevanceAdvisorySwitch(Handle handle,
    00112                                          FederateHandle federate)
    00113     throw (FederationExecutionDoesNotExist,
    00114            FederateNotExecutionMember,
    00115            SaveInProgress,
    00116            RestoreInProgress,
    00117            RTIinternalError)
    00118 {
    00119     Federation *federation = NULL ;
    00120
    00121     // It may throw RTIinternalError.
    00122     checkHandle(handle);
    00123     checkHandle(federate);
    00124
    00125     // It may throw FederationExecutionDoesNotExist.
    00126     searchFederation(handle, federation);
    00127
    00128     // It may throw a bunch of exceptions.
    00129     federation->setInteractionRelevanceAdvisorySwitch(federate);
    00130 }
    00131
    00132 // ----------------------------------------------------------------------------
    00134 void
    00135 FederationsList::unsetInteractionRelevanceAdvisorySwitch(Handle handle,
    00136                                          FederateHandle federate)
    00137     throw (FederationExecutionDoesNotExist,
    00138            FederateNotExecutionMember,
    00139            SaveInProgress,
    00140            RestoreInProgress,
    00141            RTIinternalError)
    00142 {
    00143     Federation *federation = NULL ;
    00144
    00145     // It may throw RTIinternalError.
    00146     checkHandle(handle);
    00147     checkHandle(federate);
    00148
    00149     // It may throw FederationExecutionDoesNotExist.
    00150     searchFederation(handle, federation);
    00151
    00152     // It may throw a bunch of exceptions.
    00153     federation->unsetInteractionRelevanceAdvisorySwitch(federate);
    00154 }
    00155
    00156 // ----------------------------------------------------------------------------
    00158 void
    00159 FederationsList::setAttributeRelevanceAdvisorySwitch(Handle handle,
    00160                                          FederateHandle federate)
    00161     throw (FederationExecutionDoesNotExist,
    00162            FederateNotExecutionMember,
    00163            SaveInProgress,
    00164            RestoreInProgress,
    00165            RTIinternalError)
    00166 {
    00167     Federation *federation = NULL ;
    00168
    00169     // It may throw RTIinternalError.
    00170     checkHandle(handle);
    00171     checkHandle(federate);
    00172
    00173     // It may throw FederationExecutionDoesNotExist.
    00174     searchFederation(handle, federation);
    00175
    00176     // It may throw a bunch of exceptions.
    00177     federation->setAttributeRelevanceAdvisorySwitch(federate);
    00178 }
    00179
    00180 // ----------------------------------------------------------------------------
    00182 void
    00183 FederationsList::unsetAttributeRelevanceAdvisorySwitch(Handle handle,
    00184                                          FederateHandle federate)
    00185     throw (FederationExecutionDoesNotExist,
    00186            FederateNotExecutionMember,
    00187            SaveInProgress,
    00188            RestoreInProgress,
    00189            RTIinternalError)
    00190 {
    00191     Federation *federation = NULL ;
    00192
    00193     // It may throw RTIinternalError.
    00194     checkHandle(handle);
    00195     checkHandle(federate);
    00196
    00197     // It may throw FederationExecutionDoesNotExist.
    00198     searchFederation(handle, federation);
    00199
    00200     // It may throw a bunch of exceptions.
    00201     federation->unsetAttributeRelevanceAdvisorySwitch(federate);
    00202 }
    00203
    00204 // ----------------------------------------------------------------------------
    00206 void
    00207 FederationsList::setAttributeScopeAdvisorySwitch(Handle handle,
    00208                                          FederateHandle federate)
    00209     throw (FederationExecutionDoesNotExist,
    00210            FederateNotExecutionMember,
    00211            SaveInProgress,
    00212            RestoreInProgress,
    00213            RTIinternalError)
    00214 {
    00215     Federation *federation = NULL ;
    00216
    00217     // It may throw RTIinternalError.
    00218     checkHandle(handle);
    00219     checkHandle(federate);
    00220
    00221     // It may throw FederationExecutionDoesNotExist.
    00222     searchFederation(handle, federation);
    00223
    00224     // It may throw a bunch of exceptions.
    00225     federation->setAttributeScopeAdvisorySwitch(federate);
    00226 }
    00227
    00228 // ----------------------------------------------------------------------------
    00230 void
    00231 FederationsList::unsetAttributeScopeAdvisorySwitch(Handle handle,
    00232                                          FederateHandle federate)
    00233     throw (FederationExecutionDoesNotExist,
    00234            FederateNotExecutionMember,
    00235            SaveInProgress,
    00236            RestoreInProgress,
    00237            RTIinternalError)
    00238 {
    00239     Federation *federation = NULL ;
    00240
    00241     // It may throw RTIinternalError.
    00242     checkHandle(handle);
    00243     checkHandle(federate);
    00244
    00245     // It may throw FederationExecutionDoesNotExist.
    00246     searchFederation(handle, federation);
    00247
    00248     // It may throw a bunch of exceptions.
    00249     federation->unsetAttributeScopeAdvisorySwitch(federate);
    00250 }
    00251
    00252 // ----------------------------------------------------------------------------
    00254 void
    00255 FederationsList::addConstrained(Handle handle,
    00256                                 FederateHandle federate)
    00257     throw (FederationExecutionDoesNotExist,
    00258            FederateNotExecutionMember,
    00259            SaveInProgress,
    00260            RestoreInProgress,
    00261            RTIinternalError)
    00262 {
    00263     Federation *federation = NULL ;
    00264
    00265     // It may throw RTIinternalError.
    00266     checkHandle(handle);
    00267     checkHandle(federate);
    00268
    00269     // It may throw FederationExecutionDoesNotExist.
    00270     searchFederation(handle, federation);
    00271
    00272     // It may throw a bunch of exceptions.
    00273     federation->addConstrained(federate);
    00274 }
    00275
    00276 // ----------------------------------------------------------------------------
    00282 FederateHandle
    00283 FederationsList::addFederate(Handle handle,
    00284                              const char *name,
    00285                              SocketTCP *tcp_link)
    00286     throw (FederationExecutionDoesNotExist,
    00287            FederateAlreadyExecutionMember,
    00288            MemoryExhausted,
    00289            RTIinternalError)
    00290 {
    00291
    00292     G.Out(pdGendoc,"enter FederationsList::addFederate");
    00293
    00294     // It may throw RTIinternalError
    00295     // Verify integrity of the handle of the federation
    00296     checkHandle(handle);
    00297
    00298     // It may throw FederationExecutionDoesNotExist
    00299     // Return  federation address giving its handle
    00300     Federation *federation = NULL ;
    00301     searchFederation(handle, federation);
    00302
    00303     // It may raise a bunch of exceptions
    00304     // adding the federate and return its handle
    00305     FederateHandle federate = federation->add(name, tcp_link);
    00306
    00307     G.Out(pdGendoc,"exit FederationsList::addFederate");
    00308
    00309     return federate ;
    00310 }
    00311
    00312 // ----------------------------------------------------------------------------
    00313 // searchFederation
    00314 int
    00315 FederationsList::searchFederation(Handle handle,
    00316                                   Federation* &federation)
    00317     throw (FederationExecutionDoesNotExist, RTIinternalError)
    00318 {
    00319     federation = NULL ;
    00320
    00321     // It may raise RTIinternalError
    00322     checkHandle(handle);
    00323
    00324     list<Federation *>::const_iterator i = begin();
    00325     for (int j = 1 ; i != end(); i++, j++) {
    00326         if ((*i)->getHandle() == handle) {
    00327             federation = (*i);
    00328             return j ;
    00329         }
    00330     }
    00331     D.Out(pdExcept, "Unknown Federation Handle %d.", handle);
    00332     throw FederationExecutionDoesNotExist("Bad Federation Handle.");
    00333 }
    00334
    00335 // ----------------------------------------------------------------------------
    00336 // createFederation
    00337 #ifdef FEDERATION_USES_MULTICAST
    00338
    00343 void FederationsList::createFederation(const char *name,
    00344                                        Handle handle,
    00345                                        SocketMC *mc_link)
    00346 #else
    00347
    00352     void FederationsList::createFederation(const char *name,
    00353                                            Handle handle,
    00354                                            const char *FEDid)
    00355 #endif
    00356     throw (FederationExecutionAlreadyExists,
    00357            CouldNotOpenFED,
    00358            ErrorReadingFED,
    00359            MemoryExhausted,
    00360            SecurityError,
    00361            RTIinternalError)
    00362 {
    00363     Federation *federation = NULL ;
    00364     Handle unused ;
    00365
    00366     G.Out(pdGendoc,"enter FederationsList::createFederation");
    00367     // It may throw RTIinternalError
    00368     checkHandle(handle);
    00369     auditFile << ", Handle : " << (long) handle ;
    00370     if (name == NULL) throw RTIinternalError("Invalid Federation Name.");
    00371
    00372     // It should throw FederationExecutionDoesNotExist.
    00373     try {
    00374         exists(name, unused);
    00375         D.Out(pdExcept, "Federation %s already present.", name);
    00376         G.Out(pdGendoc,"exit  FederationsList::createFederation on exception");
    00377         throw FederationExecutionAlreadyExists(name);
    00378     }
    00379     catch (FederationExecutionDoesNotExist &e) {
    00380         D.Out(pdDebug,
    00381               "CreerFederation catches FederationExecutionDoesNotExist.");
    00382     }
    00383
    00384 #ifdef FEDERATION_USES_MULTICAST
    00385     federation = new Federation(name, handle, socketServer, auditFile, mc_link, verboseLevel);
    00386 #else
    00387     try {
    00388         federation = new Federation(name, handle, socketServer, auditFile, FEDid,verboseLevel);
    00389         D.Out(pdDebug,"new Federation created.");
    00390         }
    00391     catch (CouldNotOpenFED& e) {
    00392         D.Out(pdInit, "Federation constructor : Could not open FED file.");
    00393         G.Out(pdGendoc,"exit FederationsList::createFederation on exception CouldNotOpenFED");
    00394         throw CouldNotOpenFED(e._reason);
    00395         }
    00396     catch (ErrorReadingFED &e) {
    00397         D.Out(pdInit, "Federation constructor : Could not read FED file (maybe incorrect).");
    00398         G.Out(pdGendoc,"exit FederationsList::createFederation on exception ErrorReadingFED");
    00399         throw ErrorReadingFED(e._reason);
    00400         }
    00401
    00402
    00403 #endif
    00404     if (federation == NULL)
    00405         throw MemoryExhausted("No memory left for new Federation.");
    00406
    00407     push_front(federation);
    00408     D.Out(pdInit, "New Federation created with Handle %d.", handle);
    00409
    00410     G.Out(pdGendoc,"exit FederationsList::createFederation");
    00411 }
    00412
    00413 // ----------------------------------------------------------------------------
    00414 // createRegulator
    00415 void
    00416 FederationsList::createRegulator(Handle handle,
    00417                                  FederateHandle federate,
    00418                                  FederationTime time)
    00419     throw (FederationExecutionDoesNotExist,
    00420            FederateNotExecutionMember,
    00421            SaveInProgress,
    00422            RestoreInProgress,
    00423            RTIinternalError)
    00424 {
    00425     Federation *federation = NULL ;
    00426
    00427     // It may throw RTIinternalError.
    00428     checkHandle(handle);
    00429     checkHandle(federate);
    00430
    00431     // It may throw FederationExecutionDoesNotExist.
    00432     searchFederation(handle, federation);
    00433
    00434     // It may throw a bunch of exceptions.
    00435     federation->addRegulator(federate, time);
    00436 }
    00437
    00438 // ----------------------------------------------------------------------------
    00439 // destroyObject with time
    00440 void
    00441 FederationsList::destroyObject(Handle handle,
    00442                    FederateHandle federate,
    00443                    ObjectHandle id,
    00444                    FederationTime theTime,
    00445                    const char *tag)
    00446     throw (FederateNotExecutionMember,
    00447            FederationExecutionDoesNotExist,
    00448            DeletePrivilegeNotHeld,
    00449            ObjectNotKnown,
    00450            SaveInProgress,
    00451            RestoreInProgress,
    00452        InvalidFederationTime,
    00453            RTIinternalError)
    00454 {
    00455     Federation *federation = NULL ;
    00456
    00457     // It may throw RTIinternalError.
    00458     checkHandle(handle);
    00459     checkHandle(federate);
    00460
    00461     // It may throw FederationExecutionDoesNotExist.
    00462     searchFederation(handle, federation);
    00463
    00464     federation->deleteObject(federate, id, theTime, tag);
    00465
    00466 }
    00467
    00468 // ----------------------------------------------------------------------------
    00469 // destroyObject without time
    00470 void
    00471 FederationsList::destroyObject(Handle handle,
    00472                                FederateHandle federate,
    00473                                ObjectHandle id,
    00474                                const char *tag)
    00475     throw (FederateNotExecutionMember,
    00476            FederationExecutionDoesNotExist,
    00477            DeletePrivilegeNotHeld,
    00478            ObjectNotKnown,
    00479            SaveInProgress,
    00480            RestoreInProgress,
    00481            RTIinternalError)
    00482 {
    00483     Federation *federation = NULL ;
    00484
    00485     // It may throw RTIinternalError.
    00486     checkHandle(handle);
    00487     checkHandle(federate);
    00488
    00489     // It may throw FederationExecutionDoesNotExist.
    00490     searchFederation(handle, federation);
    00491
    00492     federation->deleteObject(federate, id, tag);
    00493 }
    00494
    00495 // ----------------------------------------------------------------------------
    00499 void
    00500 FederationsList::exists(const char *name,
    00501                         Handle &handle)
    00502     throw (FederationExecutionDoesNotExist, RTIinternalError)
    00503 {
    00504     G.Out(pdGendoc,"enter FederationsList::exists");
    00505
    00506     if (name == NULL) throw RTIinternalError("Null Federation Name.");
    00507
    00508     for (list<Federation *>::iterator i = begin(); i != end(); i++) {
    00509         if (!strcmp((*i)->getName(), name)) {
    00510             handle = (*i)->getHandle();
    00511             G.Out(pdGendoc,"exit  FederationsList::exists");
    00512             return ;
    00513         }
    00514     }
    00515     G.Out(pdGendoc,"exit  FederationsList::exists on exception");
    00516
    00517     D.Out(pdDebug, "exists throws FederationExecutionDoesNotExist.");
    00518     throw FederationExecutionDoesNotExist(name);
    00519 }
    00520
    00521 // ----------------------------------------------------------------------------
    00522 // info
    00523 #ifdef FEDERATION_USES_MULTICAST
    00524 void FederationsList::info(Handle handle,
    00525                            int &nb_federates,
    00526                            int &nb_regulators,
    00527                            bool &is_syncing,
    00528                            SocketMC* &comm_mc)
    00529 #else
    00530     std::string FederationsList::info(Handle handle,
    00531                                int &nb_federates,
    00532                                int &nb_regulators,
    00533                                bool &is_syncing)
    00534 #endif
    00535     throw (FederationExecutionDoesNotExist, RTIinternalError)
    00536 {
    00537     std::string FED_Filename;
    00538     Federation *federation = NULL;
    00539     G.Out(pdGendoc,"enter FederationsList::info");
    00540     // It may raise RTIinternalError
    00541     checkHandle(handle);
    00542
    00543     // It may throw FederationExecutionNotFound
    00544     searchFederation(handle, federation);
    00545
    00546     nb_federates  = federation->getNbFederates();
    00547     nb_regulators = federation->getNbRegulators();
    00548     is_syncing    = federation->isSynchronizing();
    00549     // We need federation FEDid
    00550     FED_Filename = std::string(federation->getFEDid());
    00551 #ifdef FEDERATION_USES_MULTICAST
    00552     comm_mc = federation->MCLink ;
    00553 #endif
    00554     G.Out(pdGendoc,"exit  FederationsList::info");
    00555     // Return FEDid
    00556     return FED_Filename ;
    00557 }
    00558
    00559 // ----------------------------------------------------------------------------
    00560 // registerObject
    00561 ObjectHandle
    00562 FederationsList::registerObject(Handle handle,
    00563                                 FederateHandle federate,
    00564                                 ObjectClassHandle object_class,
    00565                                 ObjectName_t name)
    00566     throw (FederateNotExecutionMember,
    00567            FederateNotPublishing,
    00568            ObjectAlreadyRegistered,
    00569            ObjectClassNotDefined,
    00570            ObjectClassNotPublished,
    00571            SaveInProgress,
    00572            RestoreInProgress,
    00573            RTIinternalError)
    00574 {
    00575     Federation *federation = NULL ;
    00576
    00577     // It may throw RTIinternalError.
    00578     checkHandle(handle);
    00579     checkHandle(federate);
    00580     D.Out(pdTrace, "handle = %d, federate = %d.", handle, federate);
    00581
    00582     // It may throw FederationExecutionDoesNotExist.
    00583     searchFederation(handle, federation);
    00584
    00585     D.Out(pdTrace, "theObjectClass = %d, name = %s.", object_class, name.c_str());
    00586     return(federation->registerObject(federate, object_class, name.c_str()));
    00587 }
    00588
    00589 // ----------------------------------------------------------------------------
    00590 // checkHandle
    00594 void
    00595 FederationsList::checkHandle(Handle handle)
    00596     throw (RTIinternalError)
    00597 {
    00598     if (handle <= 0) {
    00599         D.Out(pdExcept, "Illegal Handle %d.", handle);
    00600         throw RTIinternalError("Negative or null Handle.");
    00601     }
    00602 }
    00603
    00604 // ----------------------------------------------------------------------------
    00605 // updateRegulator
    00606 void
    00607 FederationsList::updateRegulator(Handle handle,
    00608                                  FederateHandle federate,
    00609                                  FederationTime time)
    00610     throw (FederationExecutionDoesNotExist,
    00611            FederateNotExecutionMember,
    00612            RTIinternalError)
    00613 {
    00614     Federation *federation = NULL ;
    00615
    00616     // It may throw RTIinternalError.
    00617     checkHandle(handle);
    00618     checkHandle(federate);
    00619
    00620     // It may throw FederationExecutionDoesNotExist.
    00621     searchFederation(handle, federation);
    00622
    00623     federation->updateRegulator(federate, time);
    00624 }
    00625
    00626 // ----------------------------------------------------------------------------
    00627 // updateAttribute with time
    00628 void
    00629 FederationsList::updateAttribute(Handle handle,
    00630                                  FederateHandle federate,
    00631                                  ObjectHandle id,
    00632                                  std::vector <AttributeHandle> &attributes,
    00633                                  std::vector <AttributeValue_t> &values,
    00634                                  UShort list_size,
    00635                                  FederationTime time,
    00636                                  const char *tag)
    00637     throw (FederateNotExecutionMember,
    00638            FederationExecutionDoesNotExist,
    00639            ObjectNotKnown,
    00640            AttributeNotDefined,
    00641            AttributeNotOwned,
    00642            SaveInProgress,
    00643            RestoreInProgress,
    00644            RTIinternalError)
    00645 {
    00646     Federation *federation = NULL ;
    00647
    00648     // It may throw RTIinternalError.
    00649     checkHandle(handle);
    00650     checkHandle(federate);
    00651
    00652     // It may throw FederationExecutionDoesNotExist.
    00653     searchFederation(handle, federation);
    00654
    00655     federation->updateAttributeValues(federate, id, attributes, values,
    00656                                       list_size, time, tag);
    00657 }
    00658
    00659 // ----------------------------------------------------------------------------
    00660 // updateAttribute without time
    00661 void
    00662 FederationsList::updateAttribute(Handle handle,
    00663                                  FederateHandle federate,
    00664                                  ObjectHandle id,
    00665                                  std::vector <AttributeHandle> &attributes,
    00666                                  std::vector <AttributeValue_t> &values,
    00667                                  UShort list_size,
    00668                                  const char *tag)
    00669     throw (FederateNotExecutionMember,
    00670            FederationExecutionDoesNotExist,
    00671            ObjectNotKnown,
    00672            AttributeNotDefined,
    00673            AttributeNotOwned,
    00674            SaveInProgress,
    00675            RestoreInProgress,
    00676            RTIinternalError)
    00677 {
    00678     Federation *federation = NULL ;
    00679
    00680     // It may throw RTIinternalError.
    00681     checkHandle(handle);
    00682     checkHandle(federate);
    00683
    00684     // It may throw FederationExecutionDoesNotExist.
    00685     searchFederation(handle, federation);
    00686
    00687     federation->updateAttributeValues(federate, id, attributes, values,
    00688                                       list_size, tag);
    00689 }
    00690 // ----------------------------------------------------------------------------
    00691 // updateParameter with time
    00692 void
    00693 FederationsList::updateParameter(Handle handle,
    00694                                  FederateHandle federate,
    00695                                  InteractionClassHandle interaction,
    00696                                  std::vector <ParameterHandle> &parameters,
    00697                                  std::vector <ParameterValue_t> &values,
    00698                                  UShort list_size,
    00699                                  FederationTime time,
    00700                  RegionHandle region,
    00701                                  const char *tag)
    00702     throw (FederateNotExecutionMember,
    00703            FederateNotPublishing,
    00704            FederationExecutionDoesNotExist,
    00705            InteractionClassNotDefined,
    00706            InteractionParameterNotDefined,
    00707            SaveInProgress,
    00708            RestoreInProgress,
    00709            RTIinternalError)
    00710 {
    00711     Federation *federation = NULL ;
    00712
    00713     G.Out(pdGendoc,"enter FederationsList::updateParameter with time");
    00714
    00715     // It may throw RTIinternalError.
    00716     checkHandle(handle);
    00717     checkHandle(federate);
    00718
    00719     // It may throw FederationExecutionDoesNotExist.
    00720     searchFederation(handle, federation);
    00721
    00722     federation->broadcastInteraction(federate, interaction, parameters, values,
    00723                                      list_size, time, region, tag);
    00724
    00725     G.Out(pdGendoc,"exit FederationsList::updateParameter with time");
    00726
    00727 }
    00728
    00729 // ----------------------------------------------------------------------------
    00730 // updateParameter without time
    00731 void
    00732 FederationsList::updateParameter(Handle handle,
    00733                                  FederateHandle federate,
    00734                                  InteractionClassHandle interaction,
    00735                                  std::vector <ParameterHandle> &parameters,
    00736                                  std::vector <ParameterValue_t> &values,
    00737                                  UShort list_size,
    00738                  RegionHandle region,
    00739                                  const char *tag)
    00740     throw (FederateNotExecutionMember,
    00741            FederateNotPublishing,
    00742            FederationExecutionDoesNotExist,
    00743            InteractionClassNotDefined,
    00744            InteractionParameterNotDefined,
    00745            SaveInProgress,
    00746            RestoreInProgress,
    00747            RTIinternalError)
    00748 {
    00749     Federation *federation = NULL ;
    00750
    00751     G.Out(pdGendoc,"enter FederationsList::updateParameter without time");
    00752
    00753     // It may throw RTIinternalError.
    00754     checkHandle(handle);
    00755     checkHandle(federate);
    00756
    00757     // It may throw FederationExecutionDoesNotExist.
    00758     searchFederation(handle, federation);
    00759
    00760     federation->broadcastInteraction(federate, interaction, parameters, values,
    00761                                      list_size, region, tag);
    00762
    00763     G.Out(pdGendoc,"exit FederationsList::updateParameter without time");
    00764 }
    00765 // ----------------------------------------------------------------------------
    00769 void
    00770 FederationsList::manageSynchronization(Handle handle,
    00771                                        FederateHandle federate,
    00772                                        bool state,
    00773                                        const char *label,
    00774                                        const char *tag)
    00775     throw (FederationAlreadyPaused,
    00776            FederationNotPaused,
    00777            FederateNotExecutionMember,
    00778            SaveInProgress,
    00779            RestoreInProgress,
    00780            RTIinternalError)
    00781 {
    00782
    00783     G.Out(pdGendoc,"enter FederationsList::manageSynchronization for all federates");
    00784
    00785     checkHandle(handle); // It may throw RTIinternalError
    00786
    00787     // It may throw FederationExecutionDoesNotExist
    00788     Federation *federation = NULL ;
    00789     searchFederation(handle, federation);
    00790
    00791     // It may throw a bunch of exceptions.
    00792     if (state)
    00793         federation->registerSynchronization(federate, label, tag);
    00794     else
    00795         federation->unregisterSynchronization(federate, label);
    00796
    00797     G.Out(pdGendoc,"exit  FederationsList::manageSynchronization for all federates");
    00798
    00799 }
    00800
    00801 // ----------------------------------------------------------------------------
    00802 void
    00803 FederationsList::manageSynchronization(Handle handle,
    00804                                        FederateHandle federate,
    00805                                        bool state,
    00806                                        const char *label,
    00807                                        const char *tag,
    00808                                        unsigned short federate_setSize,
    00809                                        std::vector <FederateHandle> &federate_set)
    00810     throw (FederationAlreadyPaused,
    00811            FederationNotPaused,
    00812            FederateNotExecutionMember,
    00813            SaveInProgress,
    00814            RestoreInProgress,
    00815            RTIinternalError)
    00816 {
    00817
    00818     G.Out(pdGendoc,"enter FederationsList::manageSynchronization with federates set");
    00819
    00820     checkHandle(handle); // It may throw RTIinternalError
    00821
    00822     // It may throw FederationExecutionDoesNotExist
    00823     Federation *federation = NULL ;
    00824     searchFederation(handle, federation);
    00825
    00826     // state true means register else unregister
    00827     // It may throw a bunch of exceptions.
    00828     if (state)
    00829         federation->registerSynchronization(federate, label, tag,
    00830                                             (unsigned short)federate_setSize, federate_set);
    00831     else
    00832         federation->unregisterSynchronization(federate, label);
    00833
    00834     G.Out(pdGendoc,"exit  FederationsList::manageSynchronization with federates set");
    00835
    00836 }
    00837
    00838 // ----------------------------------------------------------------------------
    00840 void
    00841 FederationsList::broadcastSynchronization(Handle handle,
    00842                                           FederateHandle federate,
    00843                                           const char *label,
    00844                                           const char *tag)
    00845     throw (FederationExecutionDoesNotExist,
    00846            RTIinternalError)
    00847 {
    00848
    00849     G.Out(pdGendoc,"enter FederationsList::broadcastSynchronization");
    00850
    00851     checkHandle(handle); // It may throw RTIinternalError
    00852
    00853     // It may throw FederationExecutionDoesNotExist
    00854     Federation *federation = NULL ;
    00855     searchFederation(handle, federation);
    00856
    00857     federation->broadcastSynchronization(federate, label, tag);
    00858
    00859     G.Out(pdGendoc,"exit  FederationsList::broadcastSynchronization");
    00860
    00861 }
    00862
    00863 // ----------------------------------------------------------------------------
    00865 // Broadcast only on the federates into a set
    00866 void
    00867 FederationsList::broadcastSynchronization(Handle handle,
    00868                                           FederateHandle federate,
    00869                                           const char *label,
    00870                                           const char *tag,
    00871                                           unsigned short federate_setSize,
    00872                                           std::vector <FederateHandle> &federate_set)
    00873     throw (FederationExecutionDoesNotExist,
    00874            RTIinternalError)
    00875 {
    00876
    00877     G.Out(pdGendoc,"enter FederationsList::broadcastSynchronization onto a federate set");
    00878
    00879     checkHandle(handle); // It may throw RTIinternalError
    00880
    00881     // It may throw FederationExecutionDoesNotExist
    00882     Federation *federation = NULL ;
    00883     searchFederation(handle, federation);
    00884
    00885     federation->broadcastSynchronization(federate, label, tag, federate_setSize, federate_set);
    00886
    00887     G.Out(pdGendoc,"exit  FederationsList::broadcastSynchronization onto a federate set");
    00888
    00889 }
    00890
    00891
    00892 // ----------------------------------------------------------------------------
    00893 // publishInteraction
    00894 void
    00895 FederationsList::publishInteraction(Handle handle,
    00896                                     FederateHandle federate,
    00897                                     InteractionClassHandle interaction,
    00898                                     bool pub)
    00899     throw (InteractionClassNotDefined,
    00900            FederationExecutionDoesNotExist,
    00901            FederateNotExecutionMember,
    00902            SaveInProgress,
    00903            SecurityError,
    00904            RestoreInProgress,
    00905            RTIinternalError)
    00906 {
    00907     Federation *federation = NULL ;
    00908
    00909     // It may throw RTIinternalError.
    00910     checkHandle(handle);
    00911     checkHandle(federate);
    00912
    00913     // It may throw FederationExecutionDoesNotExist.
    00914     searchFederation(handle, federation);
    00915
    00916     federation->publishInteraction(federate, interaction, pub);
    00917 }
    00918
    00919 // ----------------------------------------------------------------------------
    00920 // publishObject
    00921 void
    00922 FederationsList::publishObject(Handle handle,
    00923                                FederateHandle federate,
    00924                                ObjectClassHandle object_class,
    00925                                std::vector <AttributeHandle> &attributes,
    00926                                UShort list_size,
    00927                                bool pub)
    00928     throw (ObjectClassNotDefined,
    00929            AttributeNotDefined,
    00930            FederationExecutionDoesNotExist,
    00931            FederateNotExecutionMember,
    00932            SaveInProgress,
    00933            RestoreInProgress,
    00934            SecurityError,
    00935            RTIinternalError)
    00936
    00937 {
    00938     Federation *federation = NULL ;
    00939
    00940     // It may throw RTIinternalError.
    00941     checkHandle(handle);
    00942     checkHandle(federate);
    00943
    00944     // It may throw FederationExecutionDoesNotExist.
    00945     searchFederation(handle, federation);
    00946
    00947     federation->publishObject(federate, object_class, attributes, list_size,
    00948                               pub);
    00949 }
    00950
    00951 // ----------------------------------------------------------------------------
    00952 // subscribeInteraction
    00953 void
    00954 FederationsList::subscribeInteraction(Handle handle,
    00955                                       FederateHandle federate,
    00956                                       InteractionClassHandle interaction,
    00957                                       bool sub)
    00958     throw (InteractionClassNotDefined,
    00959            FederationExecutionDoesNotExist,
    00960            FederateNotExecutionMember,
    00961            SaveInProgress,
    00962            SecurityError,
    00963            RestoreInProgress,
    00964            RTIinternalError)
    00965 {
    00966     Federation *federation = NULL ;
    00967
    00968     // It may throw RTIinternalError.
    00969     checkHandle(handle);
    00970     checkHandle(federate);
    00971
    00972     // It may throw FederationExecutionDoesNotExist.
    00973     searchFederation(handle, federation);
    00974
    00975     federation->subscribeInteraction(federate, interaction, sub);
    00976 }
    00977
    00978 // ----------------------------------------------------------------------------
    00979 // subscribeObject
    00980 void
    00981 FederationsList::subscribeObject(Handle handle,
    00982                                  FederateHandle federate,
    00983                                  ObjectClassHandle object_class,
    00984                                  std::vector <AttributeHandle> &attributes,
    00985                                  UShort list_size)
    00986     throw (ObjectClassNotDefined,
    00987            AttributeNotDefined,
    00988            FederationExecutionDoesNotExist,
    00989            FederateNotExecutionMember,
    00990            SaveInProgress,
    00991            RestoreInProgress,
    00992            SecurityError,
    00993            RTIinternalError)
    00994 {
    00995     Federation *federation = NULL ;
    00996
    00997     // It may throw RTIinternalError.
    00998     checkHandle(handle);
    00999     checkHandle(federate);
    01000
    01001     // It may throw FederationExecutionDoesNotExist.
    01002     searchFederation(handle, federation);
    01003
    01004     federation->subscribeObject(federate, object_class, attributes, list_size);
    01005 }
    01006
    01007 // ----------------------------------------------------------------------------
    01008 // removeConstrained
    01009 void
    01010 FederationsList::removeConstrained(Handle handle,
    01011                                    FederateHandle federate)
    01012     throw (FederationExecutionDoesNotExist,
    01013            FederateNotExecutionMember,
    01014            SaveInProgress,
    01015            RestoreInProgress,
    01016            RTIinternalError)
    01017 {
    01018     Federation *federation = NULL ;
    01019
    01020     // It may throw RTIinternalError.
    01021     checkHandle(handle);
    01022     checkHandle(federate);
    01023
    01024     // It may throw FederationExecutionDoesNotExist.
    01025     searchFederation(handle, federation);
    01026
    01027     // It may throw a bunch of exceptions.
    01028     federation->removeConstrained(federate);
    01029 }
    01030
    01031 // ----------------------------------------------------------------------------
    01032 // destroyFederation
    01033 void
    01034 FederationsList::destroyFederation(Handle handle)
    01035     throw (FederatesCurrentlyJoined,
    01036            FederationExecutionDoesNotExist,
    01037            RTIinternalError)
    01038 {
    01039     Federation *federation ;
    01040     list<Federation *>::iterator i ;
    01041
    01042     G.Out(pdGendoc,"enter FederationsList::destroyFederation");
    01043
    01044     // It may throw :
    01045     // RTIinternalError during checkHandle
    01046     // FederationExecutionDoesNotExist during search federation
    01047     searchFederation(handle, federation);
    01048
    01049     // It may throw FederatesCurrentlyJoined if federation not empty (in empty)
    01050     if (federation->empty()) {
    01051         for (i = begin() ; i != end() ; i++) {
    01052             if ((*i)->getHandle() == handle ) {
    01053                 // FIXME EN:comment utiliser erase(iterator) dans une boucle.
    01054                 i=erase(i);
    01055                 break;
    01056             }
    01057         }
    01058         delete federation ;
    01059     }
    01060     G.Out(pdGendoc,"exit FederationsList::destroyFederation");
    01061 }
    01062
    01063 // ----------------------------------------------------------------------------
    01064 // remove
    01065 void
    01066 FederationsList::remove(Handle handle, FederateHandle federate)
    01067     throw (FederationExecutionDoesNotExist,
    01068            FederateOwnsAttributes,
    01069            FederateNotExecutionMember,
    01070            RTIinternalError)
    01071 {
    01072     Federation *federation = NULL ;
    01073
    01074     G.Out(pdGendoc,"enter FederationsList::remove");
    01075
    01076     // It may throw RTIinternalError.
    01077     checkHandle(handle);
    01078
    01079     // It may throw FederationExecutionDoesNotExist
    01080     searchFederation(handle, federation);
    01081
    01082     // It may throw FederateOwnsAttributes or FederateNotExecutionMember
    01083     federation->remove(federate);
    01084
    01085     G.Out(pdGendoc,"exit FederationsList::remove");
    01086 }
    01087
    01088 // ----------------------------------------------------------------------------
    01089 // removeRegulator
    01090 void
    01091 FederationsList::removeRegulator(Handle handle,
    01092                                  FederateHandle federate)
    01093     throw (FederationExecutionDoesNotExist,
    01094            FederateNotExecutionMember,
    01095            SaveInProgress,
    01096            RestoreInProgress,
    01097            RTIinternalError)
    01098 {
    01099     Federation *federation = NULL ;
    01100
    01101     // It may throw RTIinternalError.
    01102     checkHandle(handle);
    01103     checkHandle(federate);
    01104
    01105     // It may throw FederationExecutionDoesNotExist.
    01106     searchFederation(handle, federation);
    01107
    01108     federation->removeRegulator(federate);
    01109 }
    01110
    01111 // ----------------------------------------------------------------------------
    01115 void
    01116 FederationsList::killFederate(Handle handle, FederateHandle federate)
    01117     throw ()
    01118 {
    01119     Federation *federation = NULL ;
    01120
    01121     try {
    01122         // It may throw RTIinternalError.
    01123         checkHandle(handle);
    01124         checkHandle(federate);
    01125
    01126         // It may throw FederationExecutionDoesNotExist.
    01127         searchFederation(handle, federation);
    01128         federation->kill(federate);
    01129     }
    01130     catch (Exception &e) {
    01131         return ;
    01132     }
    01133 }
    01134
    01135 // ----------------------------------------------------------------------------
    01136 // isOwner
    01137 bool
    01138 FederationsList::isOwner(Handle handle,
    01139                          FederateHandle federate,
    01140                          ObjectHandle id,
    01141                          AttributeHandle attribute)
    01142     throw (FederateNotExecutionMember,
    01143            ObjectNotKnown,
    01144            AttributeNotDefined,
    01145            SaveInProgress,
    01146            RestoreInProgress,
    01147            RTIinternalError)
    01148 {
    01149     Federation *f = NULL ;
    01150
    01151     // It may throw FederationExecutionDoesNotExist.
    01152     searchFederation(handle, f);
    01153
    01154     // It may throw RTIinternalError.
    01155     checkHandle(handle);
    01156     checkHandle(federate);
    01157
    01158     D.Out(pdDebug, "Owner of Attribute %u of Object %u .", attribute, id);
    01159
    01160     return(f->isOwner(federate, id, attribute));
    01161 }
    01162
    01163 // ----------------------------------------------------------------------------
    01164 // searchOwner
    01165 void
    01166 FederationsList::searchOwner(Handle handle,
    01167                              FederateHandle federate,
    01168                              ObjectHandle id,
    01169                              AttributeHandle attribute)
    01170     throw (FederateNotExecutionMember,
    01171            ObjectNotKnown,
    01172            AttributeNotDefined,
    01173            SaveInProgress,
    01174            RestoreInProgress,
    01175            RTIinternalError)
    01176 {
    01177     Federation *federation = NULL ;
    01178
    01179     // It may throw FederationExecutionDoesNotExist.
    01180     searchFederation(handle, federation);
    01181
    01182
    01183     // It may throw RTIinternalError.
    01184     checkHandle(handle);
    01185     checkHandle(federate);
    01186
    01187     D.Out(pdDebug, "Owner of Attribute %u of Object %u .", attribute, id);
    01188
    01189     federation->queryAttributeOwnership(federate, id, attribute);
    01190 }
    01191
    01192 // ----------------------------------------------------------------------------
    01193 // negotiateDivestiture
    01194 void
    01195 FederationsList::negotiateDivestiture(Handle handle,
    01196                                       FederateHandle federate,
    01197                                       ObjectHandle id,
    01198                                       std::vector <AttributeHandle> &attributes,
    01199                                       UShort list_size,
    01200                                       const char *tag)
    01201     throw (FederateNotExecutionMember,
    01202            ObjectNotKnown,
    01203            AttributeNotDefined,
    01204            AttributeNotOwned,
    01205            AttributeAlreadyBeingDivested,
    01206            SaveInProgress,
    01207            RestoreInProgress,
    01208            RTIinternalError)
    01209 {
    01210     Federation *federation = NULL ;
    01211
    01212     // It may throw FederationExecutionDoesNotExist.
    01213     searchFederation(handle, federation);
    01214
    01215     // It may throw RTIinternalError.
    01216     checkHandle(handle);
    01217     checkHandle(federate);
    01218
    01219     D.Out(pdDebug, "NegotiatedAttributeOwnershipDivestiture of Object %u.", id);
    01220
    01221     federation->negotiateDivestiture(federate, id, attributes, list_size, tag);
    01222 }
    01223
    01224 // ----------------------------------------------------------------------------
    01225 // acquireIfAvailable
    01226 void
    01227 FederationsList::acquireIfAvailable(Handle handle,
    01228                                     FederateHandle federate,
    01229                                     ObjectHandle id,
    01230                                     std::vector <AttributeHandle> &attributes,
    01231                                     UShort list_size)
    01232     throw (ObjectNotKnown,
    01233            ObjectClassNotPublished,
    01234            AttributeNotDefined,
    01235            AttributeNotPublished,
    01236            FederateOwnsAttributes,
    01237            AttributeAlreadyBeingAcquired,
    01238            FederateNotExecutionMember,
    01239            SaveInProgress,
    01240            RestoreInProgress,
    01241            RTIinternalError)
    01242 {
    01243     Federation *federation = NULL ;
    01244
    01245     // It may throw FederationExecutionDoesNotExist.
    01246     searchFederation(handle, federation);
    01247
    01248     // It may throw RTIinternalError.
    01249     checkHandle(handle);
    01250     checkHandle(federate);
    01251
    01252     federation->acquireIfAvailable(federate, id, attributes, list_size);
    01253 }
    01254
    01255 // ----------------------------------------------------------------------------
    01256 // divest
    01257 void
    01258 FederationsList::divest(Handle handle,
    01259                         FederateHandle federate,
    01260                         ObjectHandle id,
    01261                         std::vector <AttributeHandle> &attributes,
    01262                         UShort list_size)
    01263     throw (ObjectNotKnown,
    01264            AttributeNotDefined,
    01265            AttributeNotOwned,
    01266            FederateNotExecutionMember,
    01267            SaveInProgress,
    01268            RestoreInProgress,
    01269            RTIinternalError)
    01270 {
    01271     Federation *federation = NULL ;
    01272
    01273     // It may throw FederationExecutionDoesNotExist.
    01274     searchFederation(handle, federation);
    01275
    01276     // It may throw RTIinternalError.
    01277     checkHandle(handle);
    01278     checkHandle(federate);
    01279
    01280     federation->divest(federate, id, attributes, list_size);
    01281 }
    01282
    01283 // ----------------------------------------------------------------------------
    01284 // acquire
    01285 void
    01286 FederationsList::acquire(Handle handle,
    01287                          FederateHandle federate,
    01288                          ObjectHandle id,
    01289                          std::vector <AttributeHandle> &attributes,
    01290                          UShort list_size,
    01291                          const char *tag)
    01292     throw (ObjectNotKnown,
    01293            ObjectClassNotPublished,
    01294            AttributeNotDefined,
    01295            AttributeNotPublished,
    01296            FederateOwnsAttributes,
    01297            FederateNotExecutionMember,
    01298            SaveInProgress,
    01299            RestoreInProgress,
    01300            RTIinternalError)
    01301 {
    01302     Federation *federation = NULL ;
    01303
    01304     // It may throw FederationExecutionDoesNotExist.
    01305     searchFederation(handle, federation);
    01306
    01307     // It may throw RTIinternalError.
    01308     checkHandle(handle);
    01309     checkHandle(federate);
    01310
    01311     D.Out(pdDebug, "attributeOwnershipAcquisition of Object %u .", id);
    01312
    01313     federation->acquire(federate, id, attributes, list_size, tag);
    01314 }
    01315
    01316 // ----------------------------------------------------------------------------
    01317 // cancelNegotiatedAttributeOwnershipDivestiture
    01318 void
    01319 FederationsList::cancelDivestiture(Handle handle,
    01320                                    FederateHandle federate,
    01321                                    ObjectHandle id,
    01322                                    std::vector <AttributeHandle> &attributes,
    01323                                    UShort list_size)
    01324     throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    01325            AttributeDivestitureWasNotRequested, FederateNotExecutionMember,
    01326            SaveInProgress, RestoreInProgress, RTIinternalError)
    01327 {
    01328     Federation *federation = NULL ;
    01329
    01330     // It may throw FederationExecutionDoesNotExist.
    01331     searchFederation(handle, federation);
    01332
    01333     // It may throw RTIinternalError.
    01334     checkHandle(handle);
    01335     checkHandle(federate);
    01336
    01337     D.Out(pdDebug,
    01338           "cancelNegotiatedAttributeOwnershipDivestiture of Object %u .", id);
    01339
    01340     federation->cancelDivestiture(federate, id, attributes, list_size);
    01341 }
    01342
    01343 // ----------------------------------------------------------------------------
    01344 // respondRelease
    01345 AttributeHandleSet*
    01346 FederationsList::respondRelease(Handle handle,
    01347                                 FederateHandle federate,
    01348                                 ObjectHandle id,
    01349                                 std::vector <AttributeHandle> &attributes,
    01350                                 UShort list_size)
    01351     throw (ObjectNotKnown,
    01352            AttributeNotDefined,
    01353            AttributeNotOwned,
    01354            FederateWasNotAskedToReleaseAttribute,
    01355            FederateNotExecutionMember,
    01356            SaveInProgress,
    01357            RestoreInProgress,
    01358            RTIinternalError)
    01359 {
    01360     Federation *federation = NULL ;
    01361
    01362     // It may throw FederationExecutionDoesNotExist.
    01363     searchFederation(handle, federation);
    01364
    01365     // It may throw RTIinternalError.
    01366     checkHandle(handle);
    01367     checkHandle(federate);
    01368
    01369     D.Out(pdDebug, "AttributeOwnershipRealeaseResponse of Object %u .", id);
    01370
    01371     return federation->respondRelease(federate, id, attributes, list_size);
    01372 }
    01373
    01374 // ----------------------------------------------------------------------------
    01375 // cancelAcquisition
    01376 void
    01377 FederationsList::cancelAcquisition(Handle handle,
    01378                                    FederateHandle federate,
    01379                                    ObjectHandle id,
    01380                                    std::vector <AttributeHandle> &attributes,
    01381                                    UShort list_size)
    01382     throw (ObjectNotKnown,
    01383            AttributeNotDefined,
    01384            AttributeAlreadyOwned,
    01385            AttributeAcquisitionWasNotRequested,
    01386            FederateNotExecutionMember,
    01387            SaveInProgress,
    01388            RestoreInProgress,
    01389            RTIinternalError)
    01390 {
    01391     Federation *federation = NULL ;
    01392
    01393     // It may throw FederationExecutionDoesNotExist.
    01394     searchFederation(handle, federation);
    01395
    01396     // It may throw RTIinternalError.
    01397     checkHandle(handle);
    01398     checkHandle(federate);
    01399
    01400     D.Out(pdDebug, "cancelAttributeOwnershipAcquisition of Object %u .", id);
    01401
    01402     federation->cancelAcquisition(federate, id, attributes, list_size);
    01403 }
    01404
    01405 // ----------------------------------------------------------------------------
    01406 long
    01407 FederationsList::createRegion(Handle federation,
    01408                               FederateHandle federate,
    01409                               SpaceHandle space,
    01410                               long nb_extents)
    01411     throw (SpaceNotDefined, InvalidExtents, FederateNotExecutionMember,
    01412            SaveInProgress, RestoreInProgress, RTIinternalError)
    01413 {
    01414     Federation *f = 0 ;
    01415
    01416     searchFederation(federation, f);
    01417     checkHandle(federation);
    01418     checkHandle(federate);
    01419
    01420     D[pdDebug] << "Create " << nb_extents << "-extent Region "
    01421                << "in space " << space << endl ;
    01422
    01423     return f->createRegion(federate, space, nb_extents);
    01424 }
    01425
    01426 // ----------------------------------------------------------------------------
    01427 void
    01428 FederationsList::modifyRegion(Handle federation,
    01429                   FederateHandle federate,
    01430                   RegionHandle region,
    01431                   const std::vector<Extent> &extents)
    01432     throw (InvalidExtents, SaveInProgress, RestoreInProgress, RTIinternalError)
    01433 {
    01434     Federation *f = 0 ;
    01435
    01436     searchFederation(federation, f);
    01437     checkHandle(federation);
    01438     checkHandle(federate);
    01439
    01440     D[pdDebug] << "Modify region #" << region << endl ;
    01441     f->modifyRegion(federate, region, extents);
    01442 }
    01443
    01444 // ----------------------------------------------------------------------------
    01445 void
    01446 FederationsList::deleteRegion(Handle federation,
    01447                               FederateHandle federate,
    01448                               long region)
    01449     throw (RegionNotKnown, RegionInUse, FederateNotExecutionMember,
    01450            SaveInProgress, RestoreInProgress, RTIinternalError)
    01451 {
    01452     Federation *f = 0 ;
    01453
    01454     searchFederation(federation, f);
    01455     checkHandle(federation);
    01456     checkHandle(federate);
    01457
    01458     D[pdDebug] << "Delete region " << region << endl ;
    01459
    01460     f->deleteRegion(federate, region);
    01461 }
    01462
    01463 // ----------------------------------------------------------------------------
    01464 void
    01465 FederationsList::associateRegion(Handle federation,
    01466                  FederateHandle federate,
    01467                  ObjectHandle object,
    01468                  RegionHandle region,
    01469                  unsigned short nb_attributes,
    01470                  std::vector <AttributeHandle> &attributes)
    01471     throw (RegionInUse, FederateNotExecutionMember, SaveInProgress,
    01472            RestoreInProgress, RTIinternalError)
    01473 {
    01474     D[pdDebug] << "Associate region " << region << " for updates." << endl ;
    01475     D[pdDebug] << "F�:" << federation << ", F:" << federate << endl ;
    01476
    01477     Federation *f = 0 ;
    01478
    01479     searchFederation(federation, f);
    01480
    01481     checkHandle(federation);
    01482     checkHandle(federate);
    01483
    01484     f->associateRegion(federate, object, region, nb_attributes, attributes);
    01485 }
    01486
    01487 // ----------------------------------------------------------------------------
    01488 void
    01489 FederationsList::unassociateRegion(Handle federation,
    01490                    FederateHandle federate,
    01491                    ObjectHandle object,
    01492                    RegionHandle region)
    01493     throw (RegionInUse, FederateNotExecutionMember, SaveInProgress,
    01494            RestoreInProgress, RTIinternalError)
    01495 {
    01496     Federation *f = 0 ;
    01497
    01498     searchFederation(federation, f);
    01499     checkHandle(federation);
    01500     checkHandle(federate);
    01501
    01502     D[pdDebug] << "Unassociate region for updates " << region << endl ;
    01503
    01504     f->unassociateRegion(federate, object, region);
    01505 }
    01506
    01507 // ----------------------------------------------------------------------------
    01508 void
    01509 FederationsList::subscribeAttributesWR(Handle federation,
    01510                        FederateHandle federate,
    01511                        ObjectClassHandle object_class,
    01512                        RegionHandle region,
    01513                        unsigned short nb,
    01514                        std::vector <AttributeHandle> &attributes)
    01515     throw (FederateNotExecutionMember, SaveInProgress, RestoreInProgress,
    01516        RTIinternalError)
    01517 {
    01518     Federation *f = 0 ;
    01519
    01520     searchFederation(federation, f);
    01521     checkHandle(federation);
    01522     checkHandle(federate);
    01523
    01524     D[pdDebug] << " Subscribe attributes with region " << region << endl ;
    01525
    01526     f->subscribeAttributesWR(federate, object_class, region, nb, attributes);
    01527 }
    01528
    01529 // ----------------------------------------------------------------------------
    01530 void
    01531 FederationsList::unsubscribeAttributesWR(Handle federation,
    01532                      FederateHandle federate,
    01533                      ObjectClassHandle object_class,
    01534                      RegionHandle region)
    01535     throw (FederateNotExecutionMember, SaveInProgress, RestoreInProgress,
    01536        RTIinternalError)
    01537 {
    01538     Federation *f = 0 ;
    01539
    01540     searchFederation(federation, f);
    01541     checkHandle(federation);
    01542     checkHandle(federate);
    01543
    01544     D[pdDebug] << "Unsubscribe attributes with region " << region << endl ;
    01545
    01546     f->unsubscribeAttributesWR(federate, object_class, region);
    01547 }
    01548
    01549 // ----------------------------------------------------------------------------
    01550 void
    01551 FederationsList::subscribeInteractionWR(Handle federation,
    01552                     FederateHandle federate,
    01553                     InteractionClassHandle ic,
    01554                     RegionHandle region)
    01555     throw (FederateNotExecutionMember, SaveInProgress, RestoreInProgress,
    01556        RTIinternalError)
    01557 {
    01558     Federation *f = 0 ;
    01559
    01560     searchFederation(federation, f);
    01561     checkHandle(federation);
    01562     checkHandle(federate);
    01563
    01564     D[pdDebug] << "Subscribe interaction with region " << region << endl ;
    01565
    01566     f->subscribeInteractionWR(federate, ic, region);
    01567 }
    01568
    01569 // ----------------------------------------------------------------------------
    01570 void
    01571 FederationsList::unsubscribeInteractionWR(Handle federation,
    01572                       FederateHandle federate,
    01573                       InteractionClassHandle ic,
    01574                       RegionHandle region)
    01575     throw (FederateNotExecutionMember, SaveInProgress, RestoreInProgress,
    01576        RTIinternalError)
    01577 {
    01578     Federation *f = 0 ;
    01579
    01580     searchFederation(federation, f);
    01581     checkHandle(federation);
    01582     checkHandle(federate);
    01583
    01584     D[pdDebug] << "Unsubscribe interaction with region " << region << endl ;
    01585
    01586     f->unsubscribeInteractionWR(federate, ic, region);
    01587 }
    01588
    01589 // ----------------------------------------------------------------------------
    01590 // registerObjectWithRegion
    01591 ObjectHandle FederationsList::registerObjectWithRegion(Handle federation,
    01592                                FederateHandle federate,
    01593                                ObjectClassHandle handle,
    01594                                ObjectName_t tag,
    01595                                RegionHandle region,
    01596                                int nb,
    01597                                std::vector <AttributeHandle> &attrs)
    01598     throw (ObjectClassNotDefined, ObjectClassNotPublished,
    01599            AttributeNotDefined, AttributeNotPublished, RegionNotKnown,
    01600            InvalidRegionContext, ObjectAlreadyRegistered,
    01601            FederateNotExecutionMember, SaveInProgress, RestoreInProgress,
    01602            RTIinternalError)
    01603 {
    01604     Federation *f = 0 ;
    01605
    01606     searchFederation(federation, f);
    01607     checkHandle(federation);
    01608     checkHandle(federate);
    01609
    01610     return f->registerObjectWithRegion(federate, handle, tag.c_str(), region, nb, attrs);
    01611 }
    01612
    01613 // ----------------------------------------------------------------------------
    01614 // requestFederationSave with time
    01615 void
    01616 FederationsList::requestFederationSave(Handle the_federation,
    01617                                        FederateHandle the_federate,
    01618                                        const char *the_label,
    01619                                        FederationTime the_time)
    01620 {
    01621     G.Out(pdGendoc,"enter FederationsList::requestFederationSave with time");
    01622
    01623     checkHandle(the_federation);
    01624
    01625     // It may throw FederationExecutionDoesNotExist
    01626     Federation *federation = 0 ;
    01627     searchFederation(the_federation, federation);
    01628
    01629     federation->requestFederationSave(the_federate, the_label, the_time);
    01630
    01631     G.Out(pdGendoc,"exit  FederationsList::requestFederationSave with time");
    01632 }
    01633
    01634 // ----------------------------------------------------------------------------
    01635 // requestFederationSave without time
    01636 void
    01637 FederationsList::requestFederationSave(Handle the_federation,
    01638                                        FederateHandle the_federate,
    01639                                        const char *the_label)
    01640 {
    01641     G.Out(pdGendoc,"enter FederationsList::requestFederationSave without time");
    01642
    01643     checkHandle(the_federation);
    01644
    01645     // It may throw FederationExecutionDoesNotExist
    01646     Federation *federation = 0 ;
    01647     searchFederation(the_federation, federation);
    01648
    01649     federation->requestFederationSave(the_federate, the_label);
    01650
    01651     G.Out(pdGendoc,"exit  FederationsList::requestFederationSave without time");
    01652 }
    01653 // ----------------------------------------------------------------------------
    01654 void
    01655 FederationsList::federateSaveBegun(Handle the_federation,
    01656                                    FederateHandle the_federate)
    01657 {
    01658     G.Out(pdGendoc,"enter FederationsList::federateSaveBegun");
    01659
    01660     checkHandle(the_federation);
    01661
    01662     // It may throw FederationExecutionDoesNotExist
    01663     Federation *federation = 0 ;
    01664     searchFederation(the_federation, federation);
    01665
    01666     federation->federateSaveBegun(the_federate);
    01667
    01668     G.Out(pdGendoc,"exit  FederationsList::federateSaveBegun");
    01669 }
    01670
    01671 // ----------------------------------------------------------------------------
    01672 void
    01673 FederationsList::federateSaveStatus(Handle the_federation,
    01674                                     FederateHandle the_federate,
    01675                                     bool the_status)
    01676 {
    01677     G.Out(pdGendoc,"enter FederationsList::federateSaveStatus");
    01678
    01679     checkHandle(the_federation);
    01680
    01681     // It may throw FederationExecutionDoesNotExist
    01682     Federation *federation = 0 ;
    01683     searchFederation(the_federation, federation);
    01684
    01685     federation->federateSaveStatus(the_federate, the_status);
    01686
    01687     G.Out(pdGendoc,"exit  FederationsList::federateSaveStatus");
    01688 }
    01689
    01690 // ----------------------------------------------------------------------------
    01691 void
    01692 FederationsList::requestFederationRestore(Handle the_federation,
    01693                                           FederateHandle the_federate,
    01694                                           const char *the_label)
    01695 {
    01696     G.Out(pdGendoc,"enter FederationsList::requestFederationRestore");
    01697     checkHandle(the_federation);
    01698
    01699     // It may throw FederationExecutionDoesNotExist
    01700     Federation *federation = NULL ;
    01701     searchFederation(the_federation, federation);
    01702
    01703     federation->requestFederationRestore(the_federate, the_label);
    01704     G.Out(pdGendoc,"exit  FederationsList::requestFederationRestore");
    01705 }
    01706
    01707 // ----------------------------------------------------------------------------
    01708 void
    01709 FederationsList::federateRestoreStatus(Handle the_federation,
    01710                                        FederateHandle the_federate,
    01711                                        bool the_status)
    01712 {
    01713     G.Out(pdGendoc,"enter FederationsList::federateRestoreStatus");
    01714     checkHandle(the_federation);
    01715
    01716     // It may throw FederationExecutionDoesNotExist
    01717     Federation *federation = NULL ;
    01718     searchFederation(the_federation, federation);
    01719
    01720     federation->federateRestoreStatus(the_federate, the_status);
    01721     G.Out(pdGendoc,"exit  FederationsList::federateRestoreStatus");
    01722 }
    01723
    01724 // ----------------------------------------------------------------------------
    01725 // requestAttribute
    01726 FederateHandle
    01727 FederationsList::requestObjectOwner(Handle handle,
    01728                                  FederateHandle federate,
    01729                                  ObjectHandle id,
    01730                                  std::vector <AttributeHandle> &attributes,
    01731                                  UShort list_size)
    01732         throw (ObjectNotKnown,
    01733                FederationExecutionDoesNotExist,
    01734                RTIinternalError)
    01735 {
    01736     G.Out(pdGendoc,"into FederationsList::requestObjectOwner");
    01737
    01738     Federation *federation = NULL ;
    01739
    01740     // It may throw RTIinternalError.
    01741     checkHandle(handle);
    01742     checkHandle(federate);
    01743
    01744     // It may throw FederationExecutionDoesNotExist.
    01745     searchFederation(handle, federation);
    01746
    01747     // It may throw ObjectNotKnown
    01748     return(federation->requestObjectOwner(federate, id, attributes, list_size));
    01749 }
    01750
    01751 }} // certi::rtig
    01752
    01753 // EOF $Id: FederationsList.cc,v 3.63 2008/12/07 20:16:11 gotthardp Exp $
    01754