RTIambPrivateRefs.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-libRTI
00006 //
00007 // CERTI-libRTI is free software ; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License
00009 // as published by the Free Software Foundation ; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // CERTI-libRTI is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015 // Lesser General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020 // USA
00021 //
00022 // $Id: RTIambPrivateRefs.cc,v 3.19 2009/04/21 13:54:02 siron Exp $
00023 // ----------------------------------------------------------------------------
00024 
00025 #include <config.h>
00026 #include "RTIambPrivateRefs.hh"
00027 #include "RTItypesImp.hh"
00028 #include "PrettyDebug.hh"
00029 #include <sstream>
00030 
00031 namespace {
00032 static PrettyDebug D("LIBRTI", __FILE__);
00033 static PrettyDebug G("GENDOC",__FILE__);
00034 }
00035 
00036 RTIambPrivateRefs::RTIambPrivateRefs()
00037 {
00038     fed_amb      = NULL;
00039     pid_RTIA     = (pid_t)-1;
00040     is_reentrant = false;
00041     _theRootObj  = NULL;
00042     socketUn     = NULL;
00043 }
00044 
00045 RTIambPrivateRefs::~RTIambPrivateRefs()
00046 {
00047     delete socketUn ;
00048 }
00049 
00050 // ----------------------------------------------------------------------------
00051 void
00052 RTIambPrivateRefs::leave(const char *msg) throw (RTI::RTIinternalError)
00053 {
00054     std::stringstream smsg;
00055     smsg << "RTI called leave because <" <<msg<<">";
00056     throw RTI::RTIinternalError(smsg.str().c_str());
00057 }
00058 
00059 // ----------------------------------------------------------------------------
00060 void
00061 RTIambPrivateRefs::executeService(Message *req, Message *rep)
00062 {
00063     G.Out(pdGendoc,"enter RTIambPrivateRefs::executeService");
00064 
00065     D.Out(pdDebug, "sending request to RTIA.");
00066 
00067     try {
00068         req->send(socketUn,msgBufSend);
00069     }
00070     catch (NetworkError) {
00071         std::cerr << "libRTI: exception: NetworkError (write)" << std::endl ;
00072         throw RTI::RTIinternalError("libRTI: Network Write Error");
00073     }
00074 
00075     D.Out(pdDebug, "waiting RTIA reply.");
00076 
00077     // waiting RTI reply.
00078     try {
00079         rep->receive(socketUn,msgBufReceive);
00080     }
00081     catch (NetworkError) {
00082         std::cerr << "libRTI: exception: NetworkError (read)" << std::endl ;
00083         throw RTI::RTIinternalError("libRTI: Network Read Error waiting RTI reply");
00084     }
00085 
00086     D.Out(pdDebug, "RTIA reply received.");
00087 
00088 
00089     if (rep->type != req->type) {
00090         std::cout << "LibRTI: Assertion failed: rep->type != req->type" << std::endl ;
00091         throw RTI::RTIinternalError("RTIambPrivateRefs::executeService: "
00092                                "rep->type != req->type");
00093     }
00094 
00095     D.Out(pdDebug, "processing returned exception (from reply).");
00096     // the services may only throw exceptions defined in the HLA standard
00097     // the RTIA is responsible for sending 'allowed' exceptions only
00098     processException(rep);
00099 
00100     D.Out(pdDebug, "exception processed.");
00101     G.Out(pdGendoc,"exit RTIambPrivateRefs::executeService");
00102 }
00103 
00104 void
00105 RTIambPrivateRefs::sendTickRequestStop()
00106 {
00107     G.Out(pdGendoc,"enter RTIambPrivateRefs::sendTickRequestStop");
00108 
00109     Message req, rep ;
00110     req.type = Message::TICK_REQUEST_STOP;
00111 
00112     try {
00113         req.send(socketUn, msgBufSend);
00114     }
00115     catch (NetworkError) {
00116         std::cerr << "libRTI: exception: NetworkError (write)" << std::endl ;
00117         throw RTI::RTIinternalError("libRTI: Network Write Error");
00118     }
00119 
00120     try {
00121         rep.receive(socketUn, msgBufReceive);
00122     }
00123     catch (NetworkError) {
00124         std::cerr << "libRTI: exception: NetworkError (read)" << std::endl ;
00125         throw RTI::RTIinternalError("libRTI: Network Read Error waiting RTI reply");
00126     }
00127 
00128     // ignore the response, ignore exceptions
00129     // rep->type == Message::TICK_REQUEST;
00130 
00131     G.Out(pdGendoc,"exit RTIambPrivateRefs::sendTickRequestStop");
00132 }
00133 
00134 // ----------------------------------------------------------------------------
00136 
00139 void
00140 RTIambPrivateRefs::processException(Message *msg)
00141 {
00142     D.Out(pdExcept, "num de l'exception : %d .", msg->getExceptionType());
00143     switch(msg->getExceptionType()) {
00144       case e_NO_EXCEPTION: {
00145       } break ;
00146 
00147       case e_ArrayIndexOutOfBounds: {
00148           D.Out(pdExcept, "Throwing e_ArrayIndexOutOfBounds exception.");
00149           throw RTI::ArrayIndexOutOfBounds(msg->getExceptionReason());
00150       } break ;
00151 
00152       case e_AsynchronousDeliveryAlreadyEnabled: {
00153           D.Out(pdExcept, "Throwing e_AsynchronousDeliveryAlreadyEnabled exception.");
00154           throw RTI::AsynchronousDeliveryAlreadyEnabled(msg->getExceptionReason());
00155       } break ;
00156 
00157       case e_AsynchronousDeliveryAlreadyDisabled: {
00158           D.Out(pdExcept, "Throwing e_AsynchronousDeliveryAlreadyDisabled exception.");
00159           throw RTI::AsynchronousDeliveryAlreadyDisabled(msg->getExceptionReason());
00160       } break ;
00161 
00162       case e_AttributeAlreadyOwned: {
00163           D.Out(pdExcept, "Throwing e_AttributeAlreadyOwned exception.");
00164           throw RTI::AttributeAlreadyOwned(msg->getExceptionReason());
00165       } break ;
00166 
00167       case e_AttributeAlreadyBeingAcquired: {
00168           D.Out(pdExcept,
00169         "Throwing e_AttributeAlreadyBeingAcquired exception.");
00170           throw RTI::AttributeAlreadyBeingAcquired(msg->getExceptionReason());
00171       } break ;
00172 
00173       case e_AttributeAlreadyBeingDivested: {
00174           D.Out(pdExcept,
00175         "Throwing e_AttributeAlreadyBeingDivested exception.");
00176           throw RTI::AttributeAlreadyBeingDivested(msg->getExceptionReason());
00177       } break ;
00178 
00179       case e_AttributeDivestitureWasNotRequested: {
00180           D.Out(pdExcept,
00181                 "Throwing e_AttributeDivestitureWasNotRequested exception.");
00182           throw RTI::AttributeDivestitureWasNotRequested(msg->getExceptionReason());
00183       } break ;
00184 
00185       case e_AttributeAcquisitionWasNotRequested: {
00186           D.Out(pdExcept,
00187                 "Throwing e_AttributeAcquisitionWasNotRequested exception.");
00188           throw RTI::AttributeAcquisitionWasNotRequested(msg->getExceptionReason());
00189       } break ;
00190 
00191       case e_AttributeNotDefined: {
00192           D.Out(pdExcept, "Throwing e_AttributeNotDefined exception.");
00193           throw RTI::AttributeNotDefined(msg->getExceptionReason());
00194       } break ;
00195 
00196       case e_AttributeNotKnown: {
00197           D.Out(pdExcept, "Throwing e_AttributeNotKnown exception.");
00198           throw RTI::AttributeNotKnown(msg->getExceptionReason());
00199       } break ;
00200 
00201       case e_AttributeNotOwned: {
00202           D.Out(pdExcept, "Throwing e_AttributeNotOwned exception.");
00203           throw RTI::AttributeNotOwned(msg->getExceptionReason());
00204       } break ;
00205 
00206       case e_AttributeNotPublished: {
00207           D.Out(pdExcept, "Throwing e_AttributeNotPublished exception.");
00208           throw RTI::AttributeNotPublished(msg->getExceptionReason());
00209       } break ;
00210 
00211       case e_AttributeNotSubscribed: {
00212           D.Out(pdExcept, "Throwing e_AttributeNotSubscribed exception.");
00213           throw RTI::RTIinternalError(msg->getExceptionReason());
00214       } break ;
00215 
00216       case e_ConcurrentAccessAttempted: {
00217           D.Out(pdExcept, "Throwing e_ConcurrentAccessAttempted exception.");
00218           throw RTI::ConcurrentAccessAttempted(msg->getExceptionReason());
00219       } break ;
00220 
00221       case e_CouldNotDiscover: {
00222           D.Out(pdExcept, "Throwing e_CouldNotDiscover exception.");
00223           throw RTI::CouldNotDiscover(msg->getExceptionReason());
00224       } break ;
00225 
00226       case e_CouldNotOpenFED: {
00227           D.Out(pdExcept, "Throwing e_CouldNotOpenFED exception.");
00228           throw RTI::CouldNotOpenFED(msg->getExceptionReason());
00229       } break ;
00230 
00231       case e_CouldNotOpenRID: {
00232           D.Out(pdExcept, "Throwing e_CouldNotOpenRID exception.");
00233           throw RTI::RTIinternalError(msg->getExceptionReason());
00234       } break ;
00235 
00236       case e_CouldNotRestore: {
00237           D.Out(pdExcept, "Throwing e_CouldNotRestore exception.");
00238           throw RTI::CouldNotRestore(msg->getExceptionReason());
00239       } break ;
00240 
00241       case e_DeletePrivilegeNotHeld: {
00242           D.Out(pdExcept, "Throwing e_DeletePrivilegeNotHeld exception.");
00243           throw RTI::DeletePrivilegeNotHeld(msg->getExceptionReason());
00244       } break ;
00245 
00246       case e_ErrorReadingRID: {
00247           D.Out(pdExcept, "Throwing e_ErrorReadingRID exception.");
00248           throw RTI::RTIinternalError(msg->getExceptionReason());
00249       } break ;
00250 
00251       case e_ErrorReadingFED: {
00252           D.Out(pdExcept, "Throwing e_ErrorReadingFED exception.");
00253           throw RTI::ErrorReadingFED(msg->getExceptionReason());
00254       } break ;
00255 
00256       case e_EventNotKnown: {
00257           D.Out(pdExcept, "Throwing e_EventNotKnown exception.");
00258           throw RTI::EventNotKnown(msg->getExceptionReason());
00259       } break ;
00260 
00261       case e_FederateAlreadyPaused: {
00262           D.Out(pdExcept, "Throwing e_FederateAlreadyPaused exception.");
00263           throw RTI::RTIinternalError(msg->getExceptionReason());
00264       } break ;
00265 
00266       case e_FederateAlreadyExecutionMember: {
00267           D.Out(pdExcept,
00268         "Throwing e_FederateAlreadyExecutionMember exception.");
00269           throw RTI::FederateAlreadyExecutionMember(msg->getExceptionReason());
00270       } break ;
00271 
00272       case e_FederateDoesNotExist: {
00273           D.Out(pdExcept, "Throwing e_FederateDoesNotExist exception.");
00274           throw RTI::RTIinternalError(msg->getExceptionReason());
00275       } break ;
00276 
00277       case e_FederateInternalError: {
00278           D.Out(pdExcept, "Throwing e_FederateInternalError exception.");
00279           throw RTI::FederateInternalError(msg->getExceptionReason());
00280       } break ;
00281 
00282       case e_FederateNameAlreadyInUse: {
00283           D.Out(pdExcept, "Throwing e_FederateNameAlreadyInUse exception.");
00284           throw RTI::RTIinternalError(msg->getExceptionReason());
00285       } break ;
00286 
00287       case e_FederateNotExecutionMember: {
00288           D.Out(pdExcept, "Throwing e_FederateNotExecutionMember exception.");
00289           throw RTI::FederateNotExecutionMember(msg->getExceptionReason());
00290       } break ;
00291 
00292       case e_FederateNotPaused: {
00293           D.Out(pdExcept, "Throwing e_FederateNotPaused exception.");
00294           throw RTI::RTIinternalError(msg->getExceptionReason());
00295       } break ;
00296 
00297       case e_FederateOwnsAttributes: {
00298           D.Out(pdExcept, "Throwing e_FederateOwnsAttributes exception.");
00299           throw RTI::FederateOwnsAttributes(msg->getExceptionReason());
00300       } break ;
00301 
00302       case e_FederatesCurrentlyJoined: {
00303           D.Out(pdExcept, "Throwing e_FederatesCurrentlyJoined exception.");
00304           throw RTI::FederatesCurrentlyJoined(msg->getExceptionReason());
00305       } break ;
00306 
00307       case e_FederateWasNotAskedToReleaseAttribute: {
00308           D.Out(pdExcept,
00309                 "Throwing e_FederateWasNotAskedToReleaseAttribute exception.");
00310           D.Out(pdDebug,
00311                 "Throwing e_FederateWasNotAskedToReleaseAttribute exception.");
00312           throw RTI::FederateWasNotAskedToReleaseAttribute(msg->getExceptionReason());
00313       } break ;
00314 
00315       case e_FederationAlreadyPaused: {
00316           D.Out(pdExcept, "Throwing e_FederationAlreadyPaused exception.");
00317           throw RTI::RTIinternalError(msg->getExceptionReason());
00318       } break ;
00319 
00320       case e_FederationExecutionAlreadyExists: {
00321           D.Out(pdExcept, "Throwing e_FederationExecutionAlreadyExists excep.");
00322           throw RTI::FederationExecutionAlreadyExists(msg->getExceptionReason());
00323       } break ;
00324 
00325       case e_FederationExecutionDoesNotExist: {
00326           D.Out(pdExcept, "Throwing e_FederationExecutionDoesNotExist except.");
00327           throw RTI::FederationExecutionDoesNotExist(msg->getExceptionReason());
00328       } break ;
00329 
00330       case e_FederationNotPaused: {
00331           D.Out(pdExcept, "Throwing e_FederationNotPaused exception.");
00332           throw RTI::RTIinternalError(msg->getExceptionReason());
00333       } break ;
00334 
00335       case e_FederationTimeAlreadyPassed: {
00336           D.Out(pdExcept, "Throwing e_FederationTimeAlreadyPassed exception.");
00337           throw RTI::FederationTimeAlreadyPassed(msg->getExceptionReason());
00338       } break ;
00339 
00340       case e_FederateNotPublishing: {
00341           D.Out(pdExcept, "Throwing e_FederateNotPublishing exception.");
00342           throw RTI::RTIinternalError(msg->getExceptionReason());
00343       } break ;
00344 
00345       case e_FederateNotSubscribing: {
00346           D.Out(pdExcept, "Throwing e_FederateNotSubscribing exception.");
00347           throw RTI::RTIinternalError(msg->getExceptionReason());
00348       } break ;
00349 
00350       case e_RegionNotKnown: {
00351           D.Out(pdExcept, "Throwing e_RegionNotKnown exception.");
00352           throw RTI::RegionNotKnown(msg->getExceptionReason());
00353       } break ;
00354 
00355       case e_IDsupplyExhausted: {
00356           D.Out(pdExcept, "Throwing e_IDsupplyExhausted exception.");
00357           throw RTI::RTIinternalError(msg->getExceptionReason());
00358       } break ;
00359 
00360       case e_InteractionClassNotDefined: {
00361           D.Out(pdExcept, "Throwing e_InteractionClassNotDefined exception.");
00362           throw RTI::InteractionClassNotDefined(msg->getExceptionReason());
00363       } break ;
00364 
00365       case e_InteractionClassNotKnown: {
00366           D.Out(pdExcept, "Throwing e_InteractionClassNotKnown exception.");
00367           throw RTI::InteractionClassNotKnown(msg->getExceptionReason());
00368       } break ;
00369 
00370       case e_InteractionClassNotPublished: {
00371           D.Out(pdExcept, "Throwing e_InteractionClassNotPublished exception.");
00372           throw RTI::InteractionClassNotPublished(msg->getExceptionReason());
00373       } break ;
00374 
00375       case e_InteractionParameterNotDefined: {
00376           D.Out(pdExcept,
00377         "Throwing e_InteractionParameterNotDefined exception.");
00378           throw RTI::InteractionParameterNotDefined(msg->getExceptionReason());
00379       } break ;
00380 
00381       case e_InteractionParameterNotKnown: {
00382           D.Out(pdExcept, "Throwing e_InteractionParameterNotKnown exception.");
00383           throw RTI::InteractionParameterNotKnown(msg->getExceptionReason());
00384       } break ;
00385 
00386       case e_InvalidDivestitureCondition: {
00387           D.Out(pdExcept, "Throwing e_InvalidDivestitureCondition exception.");
00388           throw RTI::RTIinternalError(msg->getExceptionReason());
00389       } break ;
00390 
00391       case e_InvalidExtents: {
00392           D.Out(pdExcept, "Throwing e_InvalidExtents exception.");
00393           throw RTI::InvalidExtents(msg->getExceptionReason());
00394       } break ;
00395 
00396       case e_InvalidFederationTime: {
00397           D.Out(pdExcept, "Throwing e_InvalidFederationTime exception.");
00398           throw RTI::InvalidFederationTime(msg->getExceptionReason());
00399       } break ;
00400 
00401       case e_InvalidFederationTimeDelta: {
00402           D.Out(pdExcept, "Throwing e_InvalidFederationTimeDelta exception.");
00403           throw RTI::RTIinternalError(msg->getExceptionReason());
00404       } break ;
00405 
00406       case e_InvalidLookahead: {
00407           D.Out(pdExcept, "Throwing e_InvalidLookahead.");
00408           throw RTI::InvalidLookahead(msg->getExceptionReason());
00409       } break ;
00410 
00411       case e_InvalidObjectHandle: {
00412           D.Out(pdExcept, "Throwing e_InvalidObjectHandle exception.");
00413           throw RTI::RTIinternalError(msg->getExceptionReason());
00414       } break ;
00415 
00416       case e_InvalidOrderingHandle: {
00417           D.Out(pdExcept, "Throwing e_InvalidOrderingHandle exception.");
00418           throw RTI::InvalidOrderingHandle(msg->getExceptionReason());
00419       } break ;
00420 
00421       case e_InvalidResignAction: {
00422           D.Out(pdExcept, "Throwing e_InvalidResignAction exception.");
00423           throw RTI::InvalidResignAction(msg->getExceptionReason());
00424       } break ;
00425 
00426       case e_InvalidRetractionHandle: {
00427           D.Out(pdExcept, "Throwing e_InvalidRetractionHandle exception.");
00428           throw RTI::InvalidRetractionHandle(msg->getExceptionReason());
00429       } break ;
00430 
00431       case e_InvalidRoutingSpace: {
00432           D.Out(pdExcept, "Throwing e_InvalidRoutingSpace exception.");
00433           throw RTI::RTIinternalError(msg->getExceptionReason());
00434       } break ;
00435 
00436       case e_InvalidTransportationHandle: {
00437           D.Out(pdExcept, "Throwing e_InvalidTransportationHandle exception.");
00438           throw RTI::InvalidTransportationHandle(msg->getExceptionReason());
00439       } break ;
00440 
00441       case e_MemoryExhausted: {
00442           D.Out(pdExcept, "Throwing e_MemoryExhausted exception.");
00443           throw RTI::MemoryExhausted(msg->getExceptionReason());
00444       } break ;
00445 
00446       case e_NameNotFound: {
00447           D.Out(pdExcept, "Throwing e_NameNotFound exception.");
00448           throw RTI::NameNotFound(msg->getExceptionReason());
00449       } break ;
00450 
00451       case e_NoPauseRequested: {
00452           D.Out(pdExcept, "Throwing e_NoPauseRequested exception.");
00453           throw RTI::RTIinternalError(msg->getExceptionReason());
00454       } break ;
00455 
00456       case e_NoResumeRequested: {
00457           D.Out(pdExcept, "Throwing e_NoResumeRequested exception.");
00458           throw RTI::RTIinternalError(msg->getExceptionReason());
00459       } break ;
00460 
00461       case e_ObjectClassNotDefined: {
00462           D.Out(pdExcept, "Throwing e_ObjectClassNotDefined exception.");
00463           throw RTI::ObjectClassNotDefined(msg->getExceptionReason());
00464       } break ;
00465 
00466       case e_ObjectClassNotKnown: {
00467           D.Out(pdExcept, "Throwing e_ObjectClassNotKnown exception.");
00468           throw RTI::ObjectClassNotKnown(msg->getExceptionReason());
00469       } break ;
00470 
00471       case e_ObjectClassNotPublished: {
00472           D.Out(pdExcept, "Throwing e_ObjectClassNotPublished exception.");
00473           throw RTI::ObjectClassNotPublished(msg->getExceptionReason());
00474       } break ;
00475 
00476       case e_ObjectClassNotSubscribed: {
00477           D.Out(pdExcept, "Throwing e_ObjectClassNotSubscribed exception.");
00478           throw RTI::ObjectClassNotSubscribed(msg->getExceptionReason());
00479       } break ;
00480 
00481       case e_ObjectNotKnown: {
00482           D.Out(pdExcept, "Throwing e_ObjectNotKnown exception.");
00483           throw RTI::ObjectNotKnown(msg->getExceptionReason());
00484       } break ;
00485 
00486       case e_ObjectAlreadyRegistered: {
00487           D.Out(pdExcept, "Throwing e_ObjectAlreadyRegistered exception.");
00488           throw RTI::ObjectAlreadyRegistered(msg->getExceptionReason());
00489       } break ;
00490 
00491       case e_RestoreInProgress: {
00492           D.Out(pdExcept, "Throwing e_RestoreInProgress exception.");
00493           throw RTI::RestoreInProgress(msg->getExceptionReason());
00494       } break ;
00495 
00496       case e_RestoreNotRequested: {
00497           D.Out(pdExcept, "Throwing e_RestoreNotRequested exception.");
00498           throw RTI::RestoreNotRequested(msg->getExceptionReason());
00499       } break ;
00500 
00501       case e_RTIinternalError: {
00502           D.Out(pdExcept, "Throwing e_RTIinternalError exception.");
00503           throw RTI::RTIinternalError(msg->getExceptionReason());
00504       } break ;
00505 
00506       case e_SpaceNotDefined: {
00507           D.Out(pdExcept, "Throwing e_SpaceNotDefined exception.");
00508           throw RTI::SpaceNotDefined(msg->getExceptionReason());
00509       } break ;
00510 
00511       case e_SaveInProgress: {
00512           D.Out(pdExcept, "Throwing e_SaveInProgress exception.");
00513           throw RTI::SaveInProgress(msg->getExceptionReason());
00514       } break ;
00515 
00516       case e_SaveNotInitiated: {
00517           D.Out(pdExcept, "Throwing e_SaveNotInitiated exception.");
00518           throw RTI::SaveNotInitiated(msg->getExceptionReason());
00519       } break ;
00520 
00521       case e_SecurityError: {
00522           D.Out(pdExcept, "Throwing e_SecurityError exception.");
00523           throw RTI::RTIinternalError(msg->getExceptionReason());
00524       } break ;
00525 
00526       case e_SpecifiedSaveLabelDoesNotExist: {
00527           D.Out(pdExcept,
00528         "Throwing e_SpecifiedSaveLabelDoesNotExist exception.");
00529           throw RTI::SpecifiedSaveLabelDoesNotExist(msg->getExceptionReason());
00530       } break ;
00531 
00532       case e_TimeAdvanceAlreadyInProgress: {
00533           D.Out(pdExcept, "Throwing e_TimeAdvanceAlreadyInProgress exception.");
00534           throw RTI::TimeAdvanceAlreadyInProgress(msg->getExceptionReason());
00535       } break ;
00536 
00537       case e_TimeAdvanceWasNotInProgress: {
00538           D.Out(pdExcept, "Throwing e_TimeAdvanceWasNotInProgress exception.");
00539           throw RTI::TimeAdvanceWasNotInProgress(msg->getExceptionReason());
00540       } break ;
00541 
00542       case e_TooManyIDsRequested: {
00543           D.Out(pdExcept, "Throwing e_TooManyIDsRequested exception.");
00544           throw RTI::RTIinternalError(msg->getExceptionReason());
00545       } break ;
00546 
00547       case e_UnableToPerformSave: {
00548           D.Out(pdExcept, "Throwing e_UnableToPerformSave exception.");
00549           throw RTI::UnableToPerformSave(msg->getExceptionReason());
00550       } break ;
00551 
00552       case e_UnimplementedService: {
00553           D.Out(pdExcept, "Throwing e_UnimplementedService exception.");
00554           throw RTI::RTIinternalError(msg->getExceptionReason());
00555       } break ;
00556 
00557       case e_UnknownLabel: {
00558           D.Out(pdExcept, "Throwing e_UnknownLabel exception.");
00559           throw RTI::RTIinternalError(msg->getExceptionReason());
00560       } break ;
00561 
00562       case e_ValueCountExceeded: {
00563           D.Out(pdExcept, "Throwing e_ValueCountExceeded exception.");
00564           throw RTI::ValueCountExceeded(msg->getExceptionReason());
00565       } break ;
00566 
00567       case e_ValueLengthExceeded: {
00568           D.Out(pdExcept, "Throwing e_ValueLengthExceeded exception.");
00569           throw RTI::ValueLengthExceeded(msg->getExceptionReason());
00570       } break ;
00571 
00572       default: {
00573           D.Out(pdExcept, "Throwing unknown exception !");
00574           std::cout << "LibRTI: Receiving unknown RTI exception." << std::endl;
00575           throw RTI::RTIinternalError(msg->getExceptionReason());
00576       } break ;
00577     }
00578 }
00579 
00580 #define CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS(service) \
00581     catch (Exception &e) { \
00582         std::stringstream msg; \
00583         msg << "Error in " << service << ": " << e._name << "[" << e._reason << "]"; \
00584         throw RTI::RTIinternalError(msg.str().c_str()); \
00585     }
00586 
00587 void
00588 RTIambPrivateRefs::callFederateAmbassador(Message *msg)
00589     throw (RTI::RTIinternalError)
00590 {
00591     switch (msg->type) {
00592 
00593       case Message::SYNCHRONIZATION_POINT_REGISTRATION_SUCCEEDED:
00594         try {
00595             fed_amb->synchronizationPointRegistrationSucceeded((msg->getLabel()).c_str());
00596         }
00597         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("synchronizationPointRegistrationSucceeded")
00598         break ;
00599 
00600       case Message::ANNOUNCE_SYNCHRONIZATION_POINT:
00601         try {
00602             fed_amb->announceSynchronizationPoint((msg->getLabel()).c_str(),(msg->getTag()).c_str());
00603         }
00604         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("announceSynchronizationPoint")
00605         break ;
00606 
00607       case Message::FEDERATION_SYNCHRONIZED:
00608         try {
00609             fed_amb->federationSynchronized((msg->getLabel()).c_str());
00610         }
00611         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("federationSynchronized")
00612         break ;
00613 
00614       case Message::INITIATE_FEDERATE_SAVE:
00615         try {
00616             fed_amb->initiateFederateSave((msg->getLabel()).c_str());
00617         }
00618         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("initiateFederateSave")
00619         break ;
00620 
00621       case Message::FEDERATION_SAVED:
00622         try {
00623             fed_amb->federationSaved();
00624         }
00625         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("federationSaved")
00626         break ;
00627 
00628       case Message::REQUEST_FEDERATION_RESTORE_SUCCEEDED:
00629         try {
00630             fed_amb->requestFederationRestoreSucceeded(
00631                 (msg->getLabel()).c_str());
00632         }
00633         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("requestFederationRestoreSucceeded")
00634         break ;
00635 
00636       case Message::REQUEST_FEDERATION_RESTORE_FAILED:
00637         try {
00638             fed_amb->requestFederationRestoreFailed((msg->getLabel()).c_str(),
00639                                                 (msg->getTag()).c_str());
00640         }
00641         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("requestFederationRestoreFailed")
00642         break ;
00643 
00644       case Message::FEDERATION_RESTORE_BEGUN:
00645         try {
00646             fed_amb->federationRestoreBegun();
00647         }
00648         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("federationRestoreBegun")
00649         break ;
00650 
00651       case Message::INITIATE_FEDERATE_RESTORE:
00652         try {
00653             fed_amb->initiateFederateRestore((msg->getLabel()).c_str(),
00654                                          msg->getFederate());
00655         }
00656         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("initiateFederateRestore")
00657         break ;
00658 
00659       case Message::FEDERATION_RESTORED:
00660         try {
00661             fed_amb->federationRestored();
00662         }
00663         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("federationRestored")
00664         break ;
00665 
00666       case Message::FEDERATION_NOT_RESTORED:
00667         try {
00668             fed_amb->federationNotRestored();
00669         }
00670         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("federationNotRestored")
00671         break ;
00672 
00673       case Message::START_REGISTRATION_FOR_OBJECT_CLASS:
00674         try {
00675             fed_amb->startRegistrationForObjectClass(msg->getObjectClass());
00676         }
00677         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("startRegistrationForObjectClass")
00678         break ;
00679 
00680       case Message::STOP_REGISTRATION_FOR_OBJECT_CLASS:
00681         try {
00682             fed_amb->stopRegistrationForObjectClass(msg->getObjectClass());
00683         }
00684         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("stopRegistrationForObjectClass")
00685         break ;
00686 
00687       case Message::TURN_INTERACTIONS_ON:
00688         try {
00689             fed_amb->turnInteractionsOn(msg->getInteractionClass());
00690         }
00691         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("turnInteractionsOn")
00692         break ;
00693 
00694       case Message::TURN_INTERACTIONS_OFF:
00695         try {
00696             fed_amb->turnInteractionsOff(msg->getInteractionClass());
00697         }
00698         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("turnInteractionsOff")
00699         break ;
00700 
00701       case Message::DISCOVER_OBJECT_INSTANCE:
00702         try {
00703             fed_amb->discoverObjectInstance(msg->getObject(),
00704                                             msg->getObjectClass(),
00705                                             msg->getName().c_str());
00706         }
00707         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("discoverObjectInstance")
00708         break ;
00709 
00710       case Message::REFLECT_ATTRIBUTE_VALUES:
00711         try {
00712             G.Out(pdGendoc,"          tick_kernel call to reflectAttributeValues");
00713             RTI::AttributeHandleValuePairSet *attributes =
00714                 new AttributeHandleValuePairSetImp(msg->getAHVPS());
00715 
00716             if (msg->getBoolean())
00717                fed_amb->reflectAttributeValues(msg->getObject(),
00718                                                *attributes,
00719                                                RTIfedTime(msg->getFedTime()),
00720                                                (msg->getTag()).c_str(),
00721                                                msg->getEventRetraction());
00722             else
00723                fed_amb->reflectAttributeValues(msg->getObject(),
00724                                                *attributes,
00725                                                (msg->getTag()).c_str());
00726             delete attributes ;
00727         }
00728         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("reflectAttributeValues")
00729         break ;
00730 
00731       case Message::RECEIVE_INTERACTION:
00732         try {
00733             RTI::ParameterHandleValuePairSet *parameters =
00734                 new ParameterHandleValuePairSetImp(msg->getPHVPS());
00735 
00736             if (msg->getBoolean())
00737                 fed_amb->receiveInteraction(
00738                                         msg->getInteractionClass(),
00739                                         *parameters,
00740                                         RTIfedTime(msg->getFedTime()),
00741                                         (msg->getTag()).c_str(),
00742                                         msg->getEventRetraction());
00743             else
00744                 fed_amb->receiveInteraction(
00745                                         msg->getInteractionClass(),
00746                                         *parameters,
00747                                         (msg->getTag()).c_str());
00748 
00749             delete parameters ;
00750         }
00751         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("receiveInteraction")
00752         break ;
00753 
00754       case Message::REMOVE_OBJECT_INSTANCE:
00755         try {
00756             if (msg->getBoolean()) {
00757                 fed_amb->removeObjectInstance(
00758                                           msg->getObject(),
00759                                           RTIfedTime(msg->getFedTime()),
00760                                           (msg->getTag()).c_str(),
00761                                           msg->getEventRetraction());
00762             }
00763             else {
00764                 fed_amb->removeObjectInstance(
00765                                           msg->getObject(),
00766                                           (msg->getTag()).c_str());
00767             }
00768         }
00769         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("removeObjectInstance")
00770         break ;
00771 
00772       case Message::PROVIDE_ATTRIBUTE_VALUE_UPDATE:
00773         try {
00774             RTI::AttributeHandleSet *attributeSet =
00775                 new AttributeHandleSetImp(msg->getAHS());
00776 
00777             fed_amb->provideAttributeValueUpdate(msg->getObject(),*attributeSet);
00778             delete attributeSet ;
00779         }
00780         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("provideAttributeValueUpdate")
00781         break ;
00782 
00783       case Message::REQUEST_RETRACTION: {
00784 
00785       } break ;
00786 
00787       case Message::REQUEST_ATTRIBUTE_OWNERSHIP_ASSUMPTION:
00788         try {
00789             RTI::AttributeHandleSet *attributeSet =
00790                 new AttributeHandleSetImp(msg->getAHS());
00791 
00792             fed_amb->
00793                 requestAttributeOwnershipAssumption(msg->getObject(),
00794                                                     *attributeSet,
00795                                                     (msg->getTag()).c_str());
00796             delete attributeSet ;
00797         }
00798         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("requestAttributeOwnershipAssumption")
00799         break ;
00800 
00801       case Message::REQUEST_ATTRIBUTE_OWNERSHIP_RELEASE:
00802         try {
00803             RTI::AttributeHandleSet *attributeSet =
00804                 new AttributeHandleSetImp(msg->getAHS());
00805 
00806             fed_amb->requestAttributeOwnershipRelease(
00807                 msg->getObject(),
00808                 *attributeSet,
00809                 (msg->getTag()).c_str());
00810 
00811             delete attributeSet ;
00812         }
00813         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("requestAttributeOwnershipRelease")
00814         break ;
00815 
00816       case Message::ATTRIBUTE_OWNERSHIP_UNAVAILABLE:
00817         try {
00818             RTI::AttributeHandleSet *attributeSet =
00819                 new AttributeHandleSetImp(msg->getAHS());
00820 
00821             fed_amb->attributeOwnershipUnavailable(msg->getObject(),
00822                                                        *attributeSet);
00823 
00824             delete attributeSet ;
00825         }
00826         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("attributeOwnershipUnavailable")
00827         break ;
00828 
00829       case Message::ATTRIBUTE_OWNERSHIP_ACQUISITION_NOTIFICATION:
00830         try {
00831             RTI::AttributeHandleSet *attributeSet =
00832                 new AttributeHandleSetImp(msg->getAHS());
00833 
00834             fed_amb->attributeOwnershipAcquisitionNotification(
00835                 msg->getObject(),
00836                 *attributeSet);
00837 
00838             delete attributeSet ;
00839         }
00840         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("attributeOwnershipAcquisitionNotification")
00841         break ;
00842 
00843       case Message::ATTRIBUTE_OWNERSHIP_DIVESTITURE_NOTIFICATION:
00844         try {
00845             RTI::AttributeHandleSet *attributeSet =
00846                 new AttributeHandleSetImp(msg->getAHS());
00847 
00848             fed_amb->attributeOwnershipDivestitureNotification(
00849                 msg->getObject(),
00850                 *attributeSet);
00851 
00852             delete attributeSet ;
00853         }
00854         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("attributeOwnershipDivestitureNotification")
00855         break ;
00856 
00857       case Message::CONFIRM_ATTRIBUTE_OWNERSHIP_ACQUISITION_CANCELLATION:
00858         try {
00859             RTI::AttributeHandleSet *attributeSet =
00860                 new AttributeHandleSetImp(msg->getAHS());
00861 
00862             fed_amb->confirmAttributeOwnershipAcquisitionCancellation(
00863                 msg->getObject(),
00864                 *attributeSet);
00865 
00866             delete attributeSet ;
00867         }
00868         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("confirmAttributeOwnershipAcquisitionCancellation")
00869         break ;
00870 
00871       case Message::INFORM_ATTRIBUTE_OWNERSHIP:
00872         try {
00873             fed_amb->
00874                 informAttributeOwnership(msg->getObject(),
00875                                          msg->getAttribute(),
00876                                          msg->getFederate());
00877         }
00878         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("informAttributeOwnership")
00879         break ;
00880 
00881       case Message::ATTRIBUTE_IS_NOT_OWNED:
00882         try {
00883             fed_amb->attributeIsNotOwned(msg->getObject(),
00884                                                       msg->getAttribute());
00885         }
00886         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("attributeIsNotOwned")
00887         break ;
00888 
00889       case Message::TIME_ADVANCE_GRANT:
00890         try {
00891             fed_amb->timeAdvanceGrant(RTIfedTime(msg->getFedTime()));
00892         }
00893         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("timeAdvanceGrant")
00894         break ;
00895 
00896       case Message::TIME_REGULATION_ENABLED:
00897         try {
00898             fed_amb->timeRegulationEnabled(RTIfedTime(msg->getFedTime()));
00899         }
00900         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("timeRegulationEnabled")
00901         break ;
00902 
00903       case Message::TIME_CONSTRAINED_ENABLED:
00904         try {
00905             fed_amb->timeConstrainedEnabled(RTIfedTime(msg->getFedTime()));
00906         }
00907         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("timeConstrainedEnabled")
00908         break ;
00909 
00910       default:
00911         leave("RTI service requested by RTI is unknown.");
00912     }
00913 }
00914 
00915 // $Id: RTIambPrivateRefs.cc,v 3.19 2009/04/21 13:54:02 siron Exp $

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