certi-cvs
[Top][All Lists]
Advanced

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

[certi-cvs] certi/RTIA FederationManagement.cc FederationMa...


From: certi-cvs
Subject: [certi-cvs] certi/RTIA FederationManagement.cc FederationMa...
Date: Fri, 20 Nov 2009 16:31:31 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      09/11/20 16:31:31

Modified files:
        RTIA           : FederationManagement.cc FederationManagement.hh 

Log message:
        Check-in clean-up patch from Mathias
        patch #6984: Use a std::set for the sync labels in rtia.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.cc?cvsroot=certi&r1=3.77&r2=3.78
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.hh?cvsroot=certi&r1=3.27&r2=3.28

Patches:
Index: FederationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.cc,v
retrieving revision 3.77
retrieving revision 3.78
diff -u -b -r3.77 -r3.78
--- FederationManagement.cc     19 Nov 2009 18:15:30 -0000      3.77
+++ FederationManagement.cc     20 Nov 2009 16:31:31 -0000      3.78
@@ -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.77 2009/11/19 18:15:30 erk Exp $
+// $Id: FederationManagement.cc,v 3.78 2009/11/20 16:31:31 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -28,22 +28,11 @@
 #include "PrettyDebug.hh"
 #include "NM_Classes.hh"
 
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <list>
 #include <cstring>
 #include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <cstdlib>
-#endif
 #include <cassert>
 #include <memory>
 
-using std::list ;
-
 namespace certi {
 namespace rtia {
 
@@ -65,11 +54,8 @@
 
     _fin_execution = false ;
 
-    //_est_createur_federation = false ;
     _est_membre_federation = false ;
 
-    _nom_federation = "";
-    _nom_federe     = "";
     G.Out(pdGendoc,"exit  FederationManagement::FederationManagement");
 }
 
@@ -370,22 +356,12 @@
     D.Out(pdProtocol, "RegisterSynchronization.");
     G.Out(pdGendoc,"enter FederationManagement::registerSynchronization");
 
-    //assert(label != NULL);
-
     e = e_NO_EXCEPTION ;
 
-    list<std::string>::const_iterator i = synchronizationLabels.begin();
-    bool exists = false ;
-    for (; i != synchronizationLabels.end(); i++) {
-        if ((*i) == label) {
+    if (_synchronizationLabels.find(label) != _synchronizationLabels.end())
             e = e_FederationAlreadyPaused ; // Label already pending.
-            exists = true ;
-            break ;
-        }
-    }
 
-    if (!exists)
-        synchronizationLabels.push_back(label);
+    _synchronizationLabels.insert(label);
 
     if (!_est_membre_federation)
         e = e_FederateNotExecutionMember ;
@@ -420,22 +396,12 @@
     D.Out(pdProtocol, "RegisterSynchronization.");
     G.Out(pdGendoc,"enter FederationManagement::registerSynchronization with 
federate set");
 
-    //assert(label != NULL);
-
     e = e_NO_EXCEPTION ;
 
-    list<std::string>::const_iterator i = synchronizationLabels.begin();
-    bool exists = false ;
-    for (; i != synchronizationLabels.end(); i++) {
-        if (*i == label) {
+    if (_synchronizationLabels.find(label) != _synchronizationLabels.end())
             e = e_FederationAlreadyPaused ; // Label already pending.
-            exists = true ;
-            break ;
-        }
-    }
 
-    if (!exists)
-        synchronizationLabels.push_back(label);
+    _synchronizationLabels.insert(label);
 
     if (!_est_membre_federation)
         e = e_FederateNotExecutionMember ;
@@ -469,29 +435,14 @@
 {
     D.Out(pdProtocol, "unregisterSynchronization.");
 
-    //assert(label != NULL);
-
     e = e_NO_EXCEPTION ;
 
     // Find if this label has been requested by federate or RTIG.
-    list<std::string>::iterator i = synchronizationLabels.begin();
-    bool exists = false ;
-    for (; i != synchronizationLabels.end(); ++i) {
-        if (*i == label) {
-            // Label already pending.
-            exists = true ;
-            break ;
-        }
-    }
-    if (!exists)
+    std::set<std::string>::iterator i = _synchronizationLabels.find(label);
+    if (i == _synchronizationLabels.end())
         e = e_UnknownLabel ;
-    else {
-      /* delete[] *i ;
-       * the label has been allocated using strdup (i.e. malloc-like)
-       * so that we MUST use free (and not delete[]) to free it :))
-       */
-      synchronizationLabels.erase(i);
-    }
+    else
+      _synchronizationLabels.erase(i);
     
     if (!_est_membre_federation)
         e = e_FederateNotExecutionMember ;
@@ -521,17 +472,7 @@
     req.setTag(tag);
 
     // adding label to list of synchronizations to be done.
-    list<std::string>::const_iterator i = synchronizationLabels.begin();
-    bool exists = false ;
-    for (; i != synchronizationLabels.end(); i++) {
-        if ((*i) == label) {
-            // label exists (only if initiator).
-            exists = true ;
-            break ;
-        }
-    }
-    if (!exists)
-        synchronizationLabels.push_back(label);
+    _synchronizationLabels.insert(label);
 
     comm->requestFederateService(&req);
 }

Index: FederationManagement.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.hh,v
retrieving revision 3.27
retrieving revision 3.28
diff -u -b -r3.27 -r3.28
--- FederationManagement.hh     19 Nov 2009 18:15:30 -0000      3.27
+++ FederationManagement.hh     20 Nov 2009 16:31:31 -0000      3.28
@@ -18,12 +18,15 @@
 // 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.hh,v 3.27 2009/11/19 18:15:30 erk Exp $
+// $Id: FederationManagement.hh,v 3.28 2009/11/20 16:31:31 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIA_FEDERATION_MANAGEMENT
 #define _CERTI_RTIA_FEDERATION_MANAGEMENT
 
+#include <set>
+#include <string>
+
 #include "certi.hh"
 #include "NetworkMessage.hh"
 #include "Communications.hh"
@@ -111,13 +114,12 @@
     Communications *comm ;
     Statistics     *stat;
 
-    bool _est_createur_federation ;
     bool _est_membre_federation ;
 
     bool savingState ;
     bool restoringState ;
 
-    std::list<std::string> synchronizationLabels ; //!< Labels being 
synchronized.
+    std::set<std::string> _synchronizationLabels ; //!< Labels being 
synchronized.
 
     std::string _nom_federation ;
     std::string _nom_federe;
@@ -128,4 +130,4 @@
 
 #endif // _CERTI_RTIA_FEDERATION_MANAGEMENT
 
-// $Id: FederationManagement.hh,v 3.27 2009/11/19 18:15:30 erk Exp $
+// $Id: FederationManagement.hh,v 3.28 2009/11/20 16:31:31 erk Exp $




reply via email to

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