certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi libCERTI/ObjectClass.cc libCERTI/RootObje...


From: CERTI CVS commits
Subject: [certi-cvs] certi libCERTI/ObjectClass.cc libCERTI/RootObje...
Date: Thu, 01 Sep 2011 13:50:55 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      11/09/01 13:50:55

Modified files:
        libCERTI       : ObjectClass.cc RootObject.hh ObjectClassSet.hh 
                         ObjectClass.hh SocketServer.cc 
                         ObjectClassSet.cc 
        RTIG           : Federation.hh FederationsList.hh 
                         RTIG_processing.cc Federation.cc 
                         FederationsList.cc 
        RTIA           : DeclarationManagement.cc RTIA_federate.cc 
                         FederationManagement.cc 

Log message:
        Clean-up subscribe path while hunting bug#34016
        - Suppress unnecessary list_size argument
        - Improve comments here and there
        - replace tabs with space along the way

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.cc?cvsroot=certi&r1=3.87&r2=3.88
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RootObject.hh?cvsroot=certi&r1=3.37&r2=3.38
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.hh?cvsroot=certi&r1=3.40&r2=3.41
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.hh?cvsroot=certi&r1=3.57&r2=3.58
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketServer.cc?cvsroot=certi&r1=3.19&r2=3.20
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.cc?cvsroot=certi&r1=3.54&r2=3.55
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.hh?cvsroot=certi&r1=3.70&r2=3.71
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/FederationsList.hh?cvsroot=certi&r1=3.57&r2=3.58
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/RTIG_processing.cc?cvsroot=certi&r1=3.111&r2=3.112
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.cc?cvsroot=certi&r1=3.140&r2=3.141
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/FederationsList.cc?cvsroot=certi&r1=3.73&r2=3.74
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/DeclarationManagement.cc?cvsroot=certi&r1=3.34&r2=3.35
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA_federate.cc?cvsroot=certi&r1=3.117&r2=3.118
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.cc?cvsroot=certi&r1=3.88&r2=3.89

Patches:
Index: libCERTI/ObjectClass.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.cc,v
retrieving revision 3.87
retrieving revision 3.88
diff -u -b -r3.87 -r3.88
--- libCERTI/ObjectClass.cc     8 Jun 2011 14:40:56 -0000       3.87
+++ libCERTI/ObjectClass.cc     1 Sep 2011 13:50:54 -0000       3.88
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClass.cc,v 3.87 2011/06/08 14:40:56 erk Exp $
+// $Id: ObjectClass.cc,v 3.88 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include  "Object.hh"
@@ -768,29 +768,24 @@
 }
 
 // ----------------------------------------------------------------------------
-/** Subscribes a federate to some of this class attributes, with a
-    particular region.
-    @param fed Federate to subscribe
-    @param attributes Begining of the attribute-handle list
-    @param nb_attributes Number of attributes in the list
-    @param region Subscription region. Use 0 for default region.
-    @return true if the federate needs to discover objects of this
-    class because of this subscription
- */
 bool
 ObjectClass::subscribe(FederateHandle fed,
                const std::vector <AttributeHandle> &attributes,
-               int nb_attributes,
                const RTIRegion *region)
-throw (AttributeNotDefined, RTIinternalError, SecurityError)
-{
+throw (AttributeNotDefined, RTIinternalError, SecurityError) {
+
+    uint32_t nb_attributes = attributes.size();
        checkFederateAccess(fed, "Subscribe");
 
-       for (int i = 0 ; i < nb_attributes ; ++i) // Check attributes
+    // Verify all attributes
+    for (int i = 0 ; i < attributes.size() ; ++i) {
+        // may throw AttributeNotDefined
                getAttribute(attributes[i]);
+    }
 
-       if (nb_attributes > 0)
+    if (nb_attributes > 0) {
                maxSubscriberHandle = std::max(fed, maxSubscriberHandle);
+    }
 
        bool was_subscriber = isSubscribed(fed);
 
@@ -801,11 +796,11 @@
        << ", " << nb_attributes << " attributes, region "
        << (region ? region->getHandle() : 0) << std::endl ;
 
-       for (int i = 0 ; i < nb_attributes ; ++i) {
+    for (int i = 0 ; i < attributes.size() ; ++i) {
                getAttribute(attributes[i])->subscribe(fed, region);
        }
 
-       return (nb_attributes > 0) && !was_subscriber ;
+    return (attributes.size() > 0) && !was_subscriber ;
 } /* end of subscribe */
 
 // ----------------------------------------------------------------------------
@@ -827,7 +822,6 @@
     ObjectAttribute * oa ;
     for (int i = 0 ; i < the_size ; i++) {
         oa = object->getAttribute(the_attributes[i]);
-
         if (oa->getOwner() != the_federate)
             throw AttributeNotOwned(stringize() << "Federate 
<"<<the_federate<<"> is not owner of attribute <"<<oa->getHandle()<<">");
     }
@@ -1669,4 +1663,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClass.cc,v 3.87 2011/06/08 14:40:56 erk Exp $
+// $Id: ObjectClass.cc,v 3.88 2011/09/01 13:50:54 erk Exp $

Index: libCERTI/RootObject.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/RootObject.hh,v
retrieving revision 3.37
retrieving revision 3.38
diff -u -b -r3.37 -r3.38
--- libCERTI/RootObject.hh      15 Nov 2010 13:15:46 -0000      3.37
+++ libCERTI/RootObject.hh      1 Sep 2011 13:50:54 -0000       3.38
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: RootObject.hh,v 3.37 2010/11/15 13:15:46 erk Exp $
+// $Id: RootObject.hh,v 3.38 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef LIBCERTI_ROOT_OBJECT
@@ -130,12 +130,11 @@
     void killFederate(FederateHandle) throw (RTIinternalError);
 
     // Access to elements of the RootObject hierarchy
-    ObjectAttribute *getObjectAttribute(ObjectHandle, AttributeHandle);
-    ObjectClass *getObjectClass(ObjectClassHandle);
-    Interaction *getInteractionClass(InteractionClassHandle);
-    Object *getObject(ObjectHandle);
-    ObjectClassAttribute *getObjectClassAttribute(ObjectHandle,
-                                                 AttributeHandle);
+    ObjectAttribute*      getObjectAttribute(ObjectHandle, AttributeHandle);
+    ObjectClass*          getObjectClass(ObjectClassHandle);
+    Interaction*          getInteractionClass(InteractionClassHandle);
+    Object*               getObject(ObjectHandle);
+    ObjectClassAttribute* getObjectClassAttribute(ObjectHandle, 
AttributeHandle);
        
        void
        getAllObjectInstancesFromFederate(FederateHandle the_federate, 
std::vector<ObjectHandle>& handles);
@@ -205,4 +204,4 @@
 
 #endif // LIBCERTI_ROOT_OBJECT
 
-// $Id: RootObject.hh,v 3.37 2010/11/15 13:15:46 erk Exp $
+// $Id: RootObject.hh,v 3.38 2011/09/01 13:50:54 erk Exp $

Index: libCERTI/ObjectClassSet.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.hh,v
retrieving revision 3.40
retrieving revision 3.41
diff -u -b -r3.40 -r3.41
--- libCERTI/ObjectClassSet.hh  19 Mar 2010 13:54:03 -0000      3.40
+++ libCERTI/ObjectClassSet.hh  1 Sep 2011 13:50:54 -0000       3.41
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClassSet.hh,v 3.40 2010/03/19 13:54:03 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.41 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_OBJECT_CLASS_SET_HH
@@ -85,10 +85,18 @@
        throw (ObjectClassNotDefined, AttributeNotDefined, RTIinternalError,
                        SecurityError);
 
-       void subscribe(FederateHandle, ObjectClassHandle, const std::vector 
<AttributeHandle> &,
-                       int theListSize, const RTIRegion * = 0)
-       throw (ObjectClassNotDefined, AttributeNotDefined, RTIinternalError,
-                       SecurityError);
+    /**
+     * Subscribes a federate to a set of attributes with a region.
+     * Sends the discovery messages if necessary.
+     * @param federate Federate to subscribe
+     * @param class_handle Class to be subscribed
+     * @param attributes List of attributes to be subscribed
+     * @param region Subscription region (NULL for default)
+     */
+    void subscribe(FederateHandle, ObjectClassHandle,
+                   const std::vector <AttributeHandle>& attributes,
+                   const RTIRegion * = NULL)
+    throw (ObjectClassNotDefined, AttributeNotDefined, RTIinternalError, 
SecurityError);
 
        // Object Instance Management
        void deleteObject(FederateHandle theFederateHandle,
@@ -182,4 +190,4 @@
 
 #endif // _CERTI_OBJECT_CLASS_SET_HH
 
-// $Id: ObjectClassSet.hh,v 3.40 2010/03/19 13:54:03 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.41 2011/09/01 13:50:54 erk Exp $

Index: libCERTI/ObjectClass.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.hh,v
retrieving revision 3.57
retrieving revision 3.58
diff -u -b -r3.57 -r3.58
--- libCERTI/ObjectClass.hh     11 Jul 2011 11:17:26 -0000      3.57
+++ libCERTI/ObjectClass.hh     1 Sep 2011 13:50:54 -0000       3.58
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClass.hh,v 3.57 2011/07/11 11:17:26 erk Exp $
+// $Id: ObjectClass.hh,v 3.58 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_OBJECT_CLASS_HH
@@ -144,7 +144,16 @@
                        bool PubOrUnpub)
        throw (AttributeNotDefined, RTIinternalError, SecurityError);
 
-       bool subscribe(FederateHandle, const std::vector <AttributeHandle> &, 
int, const RTIRegion *)
+    /**
+     * Subscribes a federate to some of this class attributes,
+     * with a particular region.
+     * @param[in] federate Federate to subscribe
+     * @param[in] attributes the attribute-handle list
+     * @param[in] region Subscription region. Use 0 for default region.
+     * @return true if the federate needs to discover objects of this
+     * class because of this subscription
+     */
+    bool subscribe(FederateHandle federate, const std::vector 
<AttributeHandle>& attributes, const RTIRegion * region)
        throw (AttributeNotDefined, RTIinternalError, SecurityError);
 
        void unsubscribe(FederateHandle, const RTIRegion *);
@@ -356,4 +365,4 @@
 
 #endif // _CERTI_OBJECT_CLASS_HH
 
-// $Id: ObjectClass.hh,v 3.57 2011/07/11 11:17:26 erk Exp $
+// $Id: ObjectClass.hh,v 3.58 2011/09/01 13:50:54 erk Exp $

Index: libCERTI/SocketServer.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketServer.cc,v
retrieving revision 3.19
retrieving revision 3.20
diff -u -b -r3.19 -r3.20
--- libCERTI/SocketServer.cc    23 Mar 2010 13:13:27 -0000      3.19
+++ libCERTI/SocketServer.cc    1 Sep 2011 13:50:54 -0000       3.20
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: SocketServer.cc,v 3.19 2010/03/23 13:13:27 erk Exp $
+// $Id: SocketServer.cc,v 3.20 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -262,7 +262,7 @@
             return (*i);
     }
 
-    throw FederateNotExecutionMember("");
+    throw FederateNotExecutionMember(certi::stringize() << "Federate handle" 
<< the_federate << "is not a member of Federation" << the_federation);
 }
 
 // ----------------------------------------------------------------------------
@@ -342,4 +342,4 @@
 
 }
 
-// $Id: SocketServer.cc,v 3.19 2010/03/23 13:13:27 erk Exp $
+// $Id: SocketServer.cc,v 3.20 2011/09/01 13:50:54 erk Exp $

Index: libCERTI/ObjectClassSet.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.cc,v
retrieving revision 3.54
retrieving revision 3.55
diff -u -b -r3.54 -r3.55
--- libCERTI/ObjectClassSet.cc  11 Jul 2011 11:17:26 -0000      3.54
+++ libCERTI/ObjectClassSet.cc  1 Sep 2011 13:50:54 -0000       3.55
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClassSet.cc,v 3.54 2011/07/11 11:17:26 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.55 2011/09/01 13:50:54 erk Exp $
 // ----------------------------------------------------------------------------
 
 // Project
@@ -163,8 +163,9 @@
     ObjectClass *objectClass = 0 ;
     AttributeHandle handle ;
 
-    if (the_name.empty())
-        throw RTIinternalError("name is null");
+    if (the_name.empty()) {
+        throw RTIinternalError("provided Attribute name is null");
+    }
 
     D.Out(pdRequest, "Looking for attribute \"%s\" of class %u...",
           the_name.c_str(), the_class);
@@ -172,7 +173,6 @@
     // It may throw ObjectClassNotDefined.
     objectClass = getObjectFromHandle(the_class);
 
-
     try
         {
          handle = objectClass->getAttributeHandle(the_name);
@@ -362,30 +362,22 @@
 }
 
 // ----------------------------------------------------------------------------
-/** Subscribes a federate to a set of attributes with a region. Sends the
-    discovery messages if necessary.
-    @param federate Federate to subscribe
-    @param class_handle Class to be subscribed
-    @param attributes List of attributes to be subscribed
-    @param nb Number of attributes
-    @param region Subscription region (0 for default)
- */
 void
 ObjectClassSet::subscribe(FederateHandle federate,
                           ObjectClassHandle class_handle,
                           const std::vector <AttributeHandle> &attributes,
-                          int nb,
                          const RTIRegion *region)
     throw (ObjectClassNotDefined, AttributeNotDefined, RTIinternalError,
            SecurityError)
 {
     ObjectClass *object_class = getObjectFromHandle(class_handle);
 
-    bool need_discover = object_class->subscribe(federate, attributes, nb, 
region);
+    bool need_discover = object_class->subscribe(federate, attributes, region);
 
-    if (need_discover)
+    if (need_discover) {
        object_class->recursiveDiscovering(federate, class_handle);
-}
+    }
+} /* end of subscribe */
 
 // ----------------------------------------------------------------------------
 //! updateAttributeValues with time
@@ -634,4 +626,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClassSet.cc,v 3.54 2011/07/11 11:17:26 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.55 2011/09/01 13:50:54 erk Exp $

Index: RTIG/Federation.hh
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.hh,v
retrieving revision 3.70
retrieving revision 3.71
diff -u -b -r3.70 -r3.71
--- RTIG/Federation.hh  9 Nov 2010 22:24:26 -0000       3.70
+++ RTIG/Federation.hh  1 Sep 2011 13:50:55 -0000       3.71
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: Federation.hh,v 3.70 2010/11/09 22:24:26 erk Exp $
+// $Id: Federation.hh,v 3.71 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIG_FEDERATION_HH
@@ -319,12 +319,10 @@
      * @param[in] federate federate handle of the subscriber
      * @param[in] object subscripted object class handle 
      * @param[in] attributes subscripted vector of attributes 
-     * @param[in] list_size size of the attribute vector
     */
     void subscribeObject(FederateHandle theFederateHandle,
                          ObjectClassHandle theObjectHandle,
-                         const std::vector <AttributeHandle> &theAttributeList,
-                         uint16_t theListSize)
+                         const std::vector <AttributeHandle> &theAttributeList)
         throw (ObjectClassNotDefined,
                AttributeNotDefined,
                FederateNotExecutionMember,
@@ -723,4 +721,4 @@
 
 #endif // _CERTI_RTIG_FEDERATION_HH
 
-// $Id: Federation.hh,v 3.70 2010/11/09 22:24:26 erk Exp $
+// $Id: Federation.hh,v 3.71 2011/09/01 13:50:55 erk Exp $

Index: RTIG/FederationsList.hh
===================================================================
RCS file: /sources/certi/certi/RTIG/FederationsList.hh,v
retrieving revision 3.57
retrieving revision 3.58
diff -u -b -r3.57 -r3.58
--- RTIG/FederationsList.hh     2 Oct 2010 13:20:42 -0000       3.57
+++ RTIG/FederationsList.hh     1 Sep 2011 13:50:55 -0000       3.58
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationsList.hh,v 3.57 2010/10/02 13:20:42 erk Exp $
+// $Id: FederationsList.hh,v 3.58 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIG_FEDERATIONS_LIST_HH
@@ -308,8 +308,7 @@
     void subscribeObject(Handle theHandle,
                          FederateHandle theFederateHandle,
                          ObjectClassHandle theObjectHandle,
-                         const std::vector <AttributeHandle> &theAttributeList,
-                         uint16_t theListSize)
+                         const std::vector <AttributeHandle> &theAttributeList)
         throw (ObjectClassNotDefined,
                AttributeNotDefined,
                FederationExecutionDoesNotExist,
@@ -699,4 +698,4 @@
 
 #endif // _CERTI_RTIG_FEDERATIONS_LIST_HH
 
-// $Id: FederationsList.hh,v 3.57 2010/10/02 13:20:42 erk Exp $
+// $Id: FederationsList.hh,v 3.58 2011/09/01 13:50:55 erk Exp $

Index: RTIG/RTIG_processing.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG_processing.cc,v
retrieving revision 3.111
retrieving revision 3.112
diff -u -b -r3.111 -r3.112
--- RTIG/RTIG_processing.cc     11 Jul 2011 11:17:25 -0000      3.111
+++ RTIG/RTIG_processing.cc     1 Sep 2011 13:50:55 -0000       3.112
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIG_processing.cc,v 3.111 2011/07/11 11:17:25 erk Exp $
+// $Id: RTIG_processing.cc,v 3.112 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -150,7 +150,7 @@
 
        Handle num_federation = federations.getFederationHandle(federation);
 
-       // Need to dump the fom into that
+       // Need to dump the FOM into that
        NM_Join_Federation_Execution rep ;
        try
        {
@@ -166,7 +166,7 @@
                // Prepare answer about JoinFederationExecution
                NM_Join_Federation_Execution rep ;
                rep.setException(e_FederateAlreadyExecutionMember,
-                               "Federate with same name has yet joined the 
federation");
+               certi::stringize() << "Federate with same name <"<< federate << 
"> has already joined the federation");
 
                G.Out(pdGendoc,"processJoinFederation==>Answer to RTIA JFE 
ERROR %s",rep.getExceptionReason().c_str());
 
@@ -751,7 +751,7 @@
        G.Out(pdGendoc,"enter RTIG::processSubscribeObjectClass");
        G.Out(pdGendoc,"BEGIN **  SUBSCRIBE OBJECT CLASS SERVICE **");
 
-       std::vector <AttributeHandle> arrayVide ;
+    std::vector <AttributeHandle> emptyAttributeList;
        bool sub = (req->getMessageType() == 
NetworkMessage::SUBSCRIBE_OBJECT_CLASS);
 
        auditServer << "Subscribe Object Class = " << req->getObjectClass()
@@ -760,8 +760,7 @@
        federations.subscribeObject(req->getFederation(),
                        req->getFederate(),
                        req->getObjectClass(),
-                       sub ? req->getAttributes() : arrayVide,
-                                       sub ? req->getAttributesSize() : 0);
+                                sub ? req->getAttributes() : 
emptyAttributeList);
 
        D.Out(pdRegister,
                        "Federate %u of Federation %u subscribed to object 
class %d.",
@@ -1570,4 +1569,4 @@
 
 }} // namespace certi/rtig
 
-// $Id: RTIG_processing.cc,v 3.111 2011/07/11 11:17:25 erk Exp $
+// $Id: RTIG_processing.cc,v 3.112 2011/09/01 13:50:55 erk Exp $

Index: RTIG/Federation.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.cc,v
retrieving revision 3.140
retrieving revision 3.141
diff -u -b -r3.140 -r3.141
--- RTIG/Federation.cc  13 Jul 2011 15:43:18 -0000      3.140
+++ RTIG/Federation.cc  1 Sep 2011 13:50:55 -0000       3.141
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: Federation.cc,v 3.140 2011/07/13 15:43:18 erk Exp $
+// $Id: Federation.cc,v 3.141 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -450,7 +450,7 @@
 {
        try {
                getFederate(federate_name);
-               throw FederateAlreadyExecutionMember("");
+               throw FederateAlreadyExecutionMember(federate_name);
        }
        catch (FederateNotExecutionMember &e) {
                // Nothing to do.
@@ -1482,7 +1482,7 @@
 {
        HandleFederateMap::iterator i = 
_handleFederateMap.find(federate_handle);
        if (i == _handleFederateMap.end())
-               throw FederateNotExecutionMember("Federate Handle not found.");
+               throw FederateNotExecutionMember(certi::stringize() << 
"Federate Handle <"<< federate_handle << "> not found.");
        return i->second;
 }
 
@@ -1510,10 +1510,20 @@
 Federation::empty() const
 throw (FederatesCurrentlyJoined)
 {
-       if (_handleFederateMap.empty())
+       if (_handleFederateMap.empty()) {
                return true ;
-       else
-               throw FederatesCurrentlyJoined("");
+       }
+       else {
+           // build the list of name of the federate currently joined
+           HandleFederateMap::const_iterator it;
+           std::stringstream msg;
+           msg << "<";
+           for (it = _handleFederateMap.begin(); it != 
_handleFederateMap.end(); it++) {
+               msg << " " << (it->second).getName();
+           }
+           msg << " >";
+               throw FederatesCurrentlyJoined(msg.str().c_str());
+       }
 }
 
 // ----------------------------------------------------------------------------
@@ -1524,8 +1534,9 @@
 throw (FederateNotExecutionMember)
 {
        HandleFederateMap::const_iterator i = 
_handleFederateMap.find(federate_handle);
-       if (i == _handleFederateMap.end())
-               throw FederateNotExecutionMember("Federate Handle not found.");
+    if (i == _handleFederateMap.end()) {
+        throw FederateNotExecutionMember(certi::stringize() << "Federate 
Handle <"<< federate_handle << "> not found in federation <" << handle);
+    }
        return true;
 }
 
@@ -1731,7 +1742,7 @@
 
        D.Out(pdExcept, "Federation %d could not remove unknown federate %d.",
                        handle, federate_handle);
-       throw FederateNotExecutionMember("");
+       throw FederateNotExecutionMember(certi::stringize() << "Federate 
Handle=<"<<federate_handle <<">");
 }
 
 // ----------------------------------------------------------------------------
@@ -1866,8 +1877,7 @@
 void
 Federation::subscribeObject(FederateHandle federate,
                ObjectClassHandle object,
-               const std::vector <AttributeHandle> &attributes,
-               uint16_t list_size)
+                            const std::vector <AttributeHandle> &attributes)
 throw (ObjectClassNotDefined,
                AttributeNotDefined,
                FederateNotExecutionMember,
@@ -1880,20 +1890,23 @@
        // It may throw FederateNotExecutionMember.
        this->check(federate);
 
-       // It may throw *NotDefined
-       root->ObjectClasses->subscribe(federate, object, attributes, list_size);
-
        /*
         * The subscription process in CERTI:
         * In RTIG.cc the network messages SUBSCRIBE_OBJECT_CLASS and 
UNSUBSCRIBE_
         * OBJECT_CLASS are both mapped to the method processSubscribeObject 
within
         * RTIG_processing.cc. RTIG_proccessing invokes this method
         * (subscribeObject).
+     */
+
+    // It may throw NotDefined
+    root->ObjectClasses->subscribe(federate, object, attributes);
+
+    /*
         * The above code line (root->ObjectClasses->subscribe(...) calls the
         * subscription within the CERTI library in ObjectClassSet.cc. Further 
on,
         * ObjectClassSet::subscribe invokes ObjectClass::subscribe. That method
         * first unsubscribes all attributes, afterwards the subscription is
-        * done in a for loop til list_size.
+     * done in a for loop till list_size.
         * This means: Unsubscription and subscription are realized by the same
         * method. Only the list_size parameter controls the
         * unsubscription/subscription process.
@@ -1902,7 +1915,7 @@
         * unsubscription?
         */
 
-       if (list_size!=0) {  // do only for subscription
+    if (attributes.size()!=0) {  // do only for subscription
                // get object class from object class handle
                ObjectClass *objectClass = 
root->ObjectClasses->getObjectFromHandle(object);
 
@@ -1911,8 +1924,8 @@
 
                // get publishers of attributes
                // first for: iterate through the attribute list and get 
publishers of
-               //            each attribtue
-               // second for: iterate through the temporal publishers list and 
store
+        //            each attribute
+        // second for: iterate through the temporary publishers list and store
                //             non-duplicate entries in publishers
                ObjectClassAttribute::PublishersList_t tmp_publishers;
 
@@ -1971,7 +1984,7 @@
 
        D.Out(pdRegister,
                        "Federation %d: Federate %d(un)sub. to %d attrib. of 
ObjClass %d.",
-                       handle, federate, list_size, object);
+            handle, federate, attributes.size(), object);
        G.Out(pdGendoc,"exit  Federation::subscribeObject");
                }
 
@@ -2423,8 +2436,7 @@
                RTIinternalError)
                {
        check(federate);
-       root->ObjectClasses->subscribe(federate, c, attributes, nb,
-                       root->getRegion(region_handle));
+       root->ObjectClasses->subscribe(federate, c, attributes, 
root->getRegion(region_handle));
                }
 
 // ----------------------------------------------------------------------------
@@ -2737,5 +2749,5 @@
 
 }} // namespace certi/rtig
 
-// $Id: Federation.cc,v 3.140 2011/07/13 15:43:18 erk Exp $
+// $Id: Federation.cc,v 3.141 2011/09/01 13:50:55 erk Exp $
 

Index: RTIG/FederationsList.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/FederationsList.cc,v
retrieving revision 3.73
retrieving revision 3.74
diff -u -b -r3.73 -r3.74
--- RTIG/FederationsList.cc     2 Oct 2010 13:20:41 -0000       3.73
+++ RTIG/FederationsList.cc     1 Sep 2011 13:50:55 -0000       3.74
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationsList.cc,v 3.73 2010/10/02 13:20:41 erk Exp $
+// $Id: FederationsList.cc,v 3.74 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -783,13 +783,11 @@
 }
 
 // ----------------------------------------------------------------------------
-// subscribeObject
 void
 FederationsList::subscribeObject(Handle federationHandle,
                                  FederateHandle federate,
                                  ObjectClassHandle object_class,
-                                 const std::vector <AttributeHandle> 
&attributes,
-                                 uint16_t list_size)
+                                 const std::vector <AttributeHandle> 
&attributes)
     throw (ObjectClassNotDefined,
            AttributeNotDefined,
            FederationExecutionDoesNotExist,
@@ -802,7 +800,7 @@
     // It may throw FederationExecutionDoesNotExist.
     Federation *federation = searchFederation(federationHandle);
 
-    federation->subscribeObject(federate, object_class, attributes, list_size);
+    federation->subscribeObject(federate, object_class, attributes);
 }
 
 // ----------------------------------------------------------------------------
@@ -1450,5 +1448,5 @@
 
 }} // certi::rtig
 
-// EOF $Id: FederationsList.cc,v 3.73 2010/10/02 13:20:41 erk Exp $
+// EOF $Id: FederationsList.cc,v 3.74 2011/09/01 13:50:55 erk Exp $
 

Index: RTIA/DeclarationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/DeclarationManagement.cc,v
retrieving revision 3.34
retrieving revision 3.35
diff -u -b -r3.34 -r3.35
--- RTIA/DeclarationManagement.cc       23 Mar 2010 13:13:27 -0000      3.34
+++ RTIA/DeclarationManagement.cc       1 Sep 2011 13:50:55 -0000       3.35
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: DeclarationManagement.cc,v 3.34 2010/03/23 13:13:27 erk Exp $
+// $Id: DeclarationManagement.cc,v 3.35 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -232,11 +232,11 @@
     for (uint32_t i=0 ; i<attribArraySize ; i++)
         req.setAttributes(attribArray[i],i) ;
 
-    // Emission
+    // Send the message to RTIG
     G.Out(pdGendoc,"                              =====> send S_O_C to RTIG");
     comm->sendMessage(&req);
 
-    // Reception
+    // Wait for the RTIG answer
     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(
                       NetworkMessage::SUBSCRIBE_OBJECT_CLASS,
                       req.getFederate()));
@@ -482,4 +482,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: DeclarationManagement.cc,v 3.34 2010/03/23 13:13:27 erk Exp $
+// $Id: DeclarationManagement.cc,v 3.35 2011/09/01 13:50:55 erk Exp $

Index: RTIA/RTIA_federate.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_federate.cc,v
retrieving revision 3.117
retrieving revision 3.118
diff -u -b -r3.117 -r3.118
--- RTIA/RTIA_federate.cc       11 Jul 2011 11:17:24 -0000      3.117
+++ RTIA/RTIA_federate.cc       1 Sep 2011 13:50:55 -0000       3.118
@@ -180,7 +180,7 @@
                                throw FederateAlreadyExecutionMember("Federate 
yet joined or same name");
                                break;
                        case e_FederationExecutionDoesNotExist:
-                               throw 
FederationExecutionDoesNotExist("Federation doesn not yet exist");
+                               throw 
FederationExecutionDoesNotExist("Federation does not exist [yet]");
                                break;
                        case e_SaveInProgress:
                                throw SaveInProgress("Save in progress");

Index: RTIA/FederationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.cc,v
retrieving revision 3.88
retrieving revision 3.89
diff -u -b -r3.88 -r3.89
--- RTIA/FederationManagement.cc        15 Nov 2010 13:15:47 -0000      3.88
+++ RTIA/FederationManagement.cc        1 Sep 2011 13:50:55 -0000       3.89
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationManagement.cc,v 3.88 2010/11/15 13:15:47 erk Exp $
+// $Id: FederationManagement.cc,v 3.89 2011/09/01 13:50:55 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -262,7 +262,8 @@
             _nom_federe = Federate;
             _numero_federation = reponse->getFederation() ;
             federate = reponse->getFederate();
-            tm->setFederate(reponse->getFederate());
+            //std::cout << "federate ID=" << federate << std::endl;
+            tm->setFederate(federate);
 #ifdef FEDERATION_USES_MULTICAST
             // creation du socket pour la communication best-effort
             comm->CreerSocketMC(reponse->AdresseMulticast, MC_PORT);
@@ -279,8 +280,9 @@
             G.Out(pdGendoc,"exit(%d) 
FederationManagement::joinFederationExecution",federate);
             return(federate);
         }
-        else
-            e = reponse->getException() ;
+        else {
+            e = reponse->getException();
+        }
     }
     G.Out(pdGendoc,"exit(0) FederationManagement::joinFederationExecution");
     return(0);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]