certi-cvs
[Top][All Lists]
Advanced

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

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


From: certi-cvs
Subject: [certi-cvs] certi RTIA/FederationManagement.cc RTIA/Federat...
Date: Sun, 14 Mar 2010 15:35:54 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Petr Gotthard <gotthardp>       10/03/14 15:35:54

Modified files:
        RTIA           : FederationManagement.cc FederationManagement.hh 
                         RTIA.cc RTIA.hh RTIA_federate.cc Statistics.cc 
        libCERTI       : M_Classes.cc M_Classes.hh Message.hh 
        libRTI         : RTIambassador.cc 
        scripts        : CERTI_Message.msg CERTI_NetworkMessage.msg 
                         GenMsgAST.py GenMsgCXX.py GenerateMessages.py 

Log message:
        Bug #24854: Implemented protocol compatibility checks for the 
Federate--RTIA channel.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.cc?cvsroot=certi&r1=3.81&r2=3.82
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.hh?cvsroot=certi&r1=3.30&r2=3.31
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.cc?cvsroot=certi&r1=3.31&r2=3.32
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.hh?cvsroot=certi&r1=3.19&r2=3.20
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA_federate.cc?cvsroot=certi&r1=3.105&r2=3.106
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/Statistics.cc?cvsroot=certi&r1=3.21&r2=3.22
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/M_Classes.cc?cvsroot=certi&r1=3.6&r2=3.7
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/M_Classes.hh?cvsroot=certi&r1=3.6&r2=3.7
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Message.hh?cvsroot=certi&r1=3.61&r2=3.62
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/RTIambassador.cc?cvsroot=certi&r1=3.114&r2=3.115
http://cvs.savannah.gnu.org/viewcvs/certi/scripts/CERTI_Message.msg?cvsroot=certi&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/certi/scripts/CERTI_NetworkMessage.msg?cvsroot=certi&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/certi/scripts/GenMsgAST.py?cvsroot=certi&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/certi/scripts/GenMsgCXX.py?cvsroot=certi&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/certi/scripts/GenerateMessages.py?cvsroot=certi&r1=1.35&r2=1.36

Patches:
Index: RTIA/FederationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.cc,v
retrieving revision 3.81
retrieving revision 3.82
diff -u -b -r3.81 -r3.82
--- RTIA/FederationManagement.cc        7 Mar 2010 18:23:40 -0000       3.81
+++ RTIA/FederationManagement.cc        14 Mar 2010 15:35:53 -0000      3.82
@@ -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.81 2010/03/07 18:23:40 erk Exp $
+// $Id: FederationManagement.cc,v 3.82 2010/03/14 15:35:53 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -53,7 +53,7 @@
     _numero_federation = 0 ;
     federate = 0 ;
 
-    _fin_execution = false ;
+    _connection_state = CONNECTION_PRELUDE;
 
     _est_membre_federation = false ;
 

Index: RTIA/FederationManagement.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.hh,v
retrieving revision 3.30
retrieving revision 3.31
diff -u -b -r3.30 -r3.31
--- RTIA/FederationManagement.hh        7 Mar 2010 18:23:40 -0000       3.30
+++ RTIA/FederationManagement.hh        14 Mar 2010 15:35:53 -0000      3.31
@@ -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.hh,v 3.30 2010/03/07 18:23:40 erk Exp $
+// $Id: FederationManagement.hh,v 3.31 2010/03/14 15:35:53 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIA_FEDERATION_MANAGEMENT
@@ -108,7 +108,21 @@
     TimeManagement *tm ;
     Handle _numero_federation ;
     FederateHandle federate ;
-    bool _fin_execution ;
+
+    /**
+     * State of the connection towards the federate. The state is changed
+     * through the OPEN_CONNEXION and CLOSE_CONNEXION messages.
+     */
+    typedef enum ConnectionState {
+        //! Initial state before OPEN_CONNEXION; no other message allowed.
+        CONNECTION_PRELUDE,
+        //! Communication is active.
+        CONNECTION_READY,
+        //! State after CLOSE_CONNEXION; no further messages allowed.
+        CONNECTION_FIN
+    } ConnectionState_t;
+
+    ConnectionState_t _connection_state;
 
 private:
     Communications *comm ;
@@ -130,4 +144,4 @@
 
 #endif // _CERTI_RTIA_FEDERATION_MANAGEMENT
 
-// $Id: FederationManagement.hh,v 3.30 2010/03/07 18:23:40 erk Exp $
+// $Id: FederationManagement.hh,v 3.31 2010/03/14 15:35:53 gotthardp Exp $

Index: RTIA/RTIA.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.cc,v
retrieving revision 3.31
retrieving revision 3.32
diff -u -b -r3.31 -r3.32
--- RTIA/RTIA.cc        18 Nov 2009 18:50:48 -0000      3.31
+++ RTIA/RTIA.cc        14 Mar 2010 15:35:53 -0000      3.32
@@ -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: RTIA.cc,v 3.31 2009/11/18 18:50:48 erk Exp $
+// $Id: RTIA.cc,v 3.32 2010/03/14 15:35:53 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -97,7 +97,7 @@
     NetworkMessage *msg_tcp_udp;
     int n ;
 
-    while (!fm->_fin_execution) {
+    while (fm->_connection_state != FederationManagement::CONNECTION_FIN) {
        
         /* 
          * readMessage call will allocate EITHER a Network Message or a 
Message 
@@ -148,7 +148,7 @@
             /* timev is undefined after select() */
         }
         catch (NetworkSignal) {
-            fm->_fin_execution = true ;
+            fm->_connection_state = FederationManagement::CONNECTION_FIN;
             n = 0 ;
             delete msg_un ;
             delete msg_tcp_udp ;
@@ -180,4 +180,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: RTIA.cc,v 3.31 2009/11/18 18:50:48 erk Exp $
+// $Id: RTIA.cc,v 3.32 2010/03/14 15:35:53 gotthardp Exp $

Index: RTIA/RTIA.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.hh,v
retrieving revision 3.19
retrieving revision 3.20
diff -u -b -r3.19 -r3.20
--- RTIA/RTIA.hh        27 Feb 2010 16:53:36 -0000      3.19
+++ RTIA/RTIA.hh        14 Mar 2010 15:35:53 -0000      3.20
@@ -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: RTIA.hh,v 3.19 2010/02/27 16:53:36 erk Exp $
+// $Id: RTIA.hh,v 3.20 2010/03/14 15:35:53 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIA_HH
@@ -106,6 +106,14 @@
 
     /**
      * The method called by processFederateRequest in order to
+     * process requests in the FederationManagement::CONNECTION_PRELUDE state.
+     * @param[in] request the federate request message
+     * @param[out] answer answer message to be sent back to the federate
+     */
+    void initFederateProcessing(Message *request, Message* answer);
+
+    /**
+     * The method called by processFederateRequest in order to
      * effectively process the request and build the appropriate
      * answer.
      * @param[in] request the federate request message
@@ -124,4 +132,4 @@
 
 #endif // _CERTI_RTIA_HH
 
-// $Id: RTIA.hh,v 3.19 2010/02/27 16:53:36 erk Exp $
+// $Id: RTIA.hh,v 3.20 2010/03/14 15:35:53 gotthardp Exp $

Index: RTIA/RTIA_federate.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_federate.cc,v
retrieving revision 3.105
retrieving revision 3.106
diff -u -b -r3.105 -r3.106
--- RTIA/RTIA_federate.cc       7 Mar 2010 18:23:40 -0000       3.105
+++ RTIA/RTIA_federate.cc       14 Mar 2010 15:35:53 -0000      3.106
@@ -51,6 +51,7 @@
        //D.Mes(pdMessage, 'N', type);
 
        switch (type) {
+       case Message::OPEN_CONNEXION:
        case Message::CLOSE_CONNEXION:
        case Message::RESIGN_FEDERATION_EXECUTION:
        case Message::TICK_REQUEST:
@@ -112,7 +113,7 @@
        case Message::CLOSE_CONNEXION:
                D.Out(pdTrace,
                                "Receiving Message from Federate, type 
CloseConnexion.");
-               fm->_fin_execution = true;
+               fm->_connection_state = FederationManagement::CONNECTION_FIN;
                // the this->comm can now be used only to sent the 
CLOSE_CONNEXION response
                break ;
 
@@ -1313,6 +1314,36 @@
 } /* RTIA::processOngoingTick() */
 
 void
+RTIA::initFederateProcessing(Message *req, Message* rep)
+{
+       if(req->getType() == Message::OPEN_CONNEXION) {
+               M_Open_Connexion *OCq, *OCr;
+               OCq = static_cast<M_Open_Connexion *>(req);
+               OCr = static_cast<M_Open_Connexion *>(rep);
+
+               if(OCq->getVersionMajor() == CERTI_Message::versionMajor) {
+                       uint32_t minorEffective = OCq->getVersionMinor() < 
CERTI_Message::versionMinor
+                               ? OCq->getVersionMinor() : 
CERTI_Message::versionMinor;
+                       OCr->setVersionMajor(CERTI_Message::versionMajor);
+                       OCr->setVersionMinor(minorEffective);
+
+                       fm->_connection_state = 
FederationManagement::CONNECTION_READY;
+               }
+               else {
+                       rep->setException(e_RTIinternalError, stringize()
+                               << "RTIA protocol version mismatch"
+                               << "; federate " << OCq->getVersionMajor() << 
"." << OCq->getVersionMinor()
+                               << ", RTIA " << CERTI_Message::versionMajor << 
"." << CERTI_Message::versionMinor);
+               }
+       }
+       else {
+               rep->setException(e_RTIinternalError,
+                       "RTIA protocol version mismatch; expecting 
OPEN_CONNECTION first.");
+       }
+       stat.federateService(req->getType());
+}
+
+void
 RTIA::processFederateRequest(Message *req)
 {
        /* use virtual constructor in order to build  *
@@ -1322,11 +1353,27 @@
        G.Out(pdGendoc,"enter RTIA::processFederateRequest");
 
        try {
+               switch(fm->_connection_state) {
+               case FederationManagement::CONNECTION_PRELUDE:
+                       initFederateProcessing(req, rep.get());
+                       break;
+
+               case FederationManagement::CONNECTION_READY:
+               {
                TypeException exc ;
                chooseFederateProcessing(req, rep.get(), exc);
                if ( exc != e_RTIinternalError && exc != e_NO_EXCEPTION) {
                        rep->setException(exc);
                }
+                       break;
+               }
+
+               case FederationManagement::CONNECTION_FIN:
+               default:
+                       rep->setException(e_RTIinternalError,
+                               "RTIA connection already closed.");
+                       break;
+               }
        }
        // FIXME should
        // catch (Exception &e) {

Index: RTIA/Statistics.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/Statistics.cc,v
retrieving revision 3.21
retrieving revision 3.22
diff -u -b -r3.21 -r3.22
--- RTIA/Statistics.cc  19 Nov 2009 18:15:30 -0000      3.21
+++ RTIA/Statistics.cc  14 Mar 2010 15:35:53 -0000      3.22
@@ -56,6 +56,7 @@
        myDisplay = false ;
 
     if (!initialized) {
+        FED_MSG_NAME(Message::OPEN_CONNEXION);
         FED_MSG_NAME(Message::CLOSE_CONNEXION);
 
         // Federation
@@ -373,4 +374,4 @@
 #undef FED_MSG_NAME
 #undef RTI_MSG_NAME
 
-// $Id: Statistics.cc,v 3.21 2009/11/19 18:15:30 erk Exp $
+// $Id: Statistics.cc,v 3.22 2010/03/14 15:35:53 gotthardp Exp $

Index: libCERTI/M_Classes.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/M_Classes.cc,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -b -r3.6 -r3.7
--- libCERTI/M_Classes.cc       8 Mar 2010 11:35:30 -0000       3.6
+++ libCERTI/M_Classes.cc       14 Mar 2010 15:35:54 -0000      3.7
@@ -1,4 +1,4 @@
-// Generated on 2010 March Mon, 08 at 09:41:06 by the CERTI message generator
+// Generated on 2010 March Sun, 14 at 16:30:18 by the CERTI message generator
 #include <vector>
 #include <string>
 #include "M_Classes.hh"
@@ -53,6 +53,40 @@
       out << " SN = " << SN << " "       << std::endl;
       out << "[EventRetraction -End]" << std::endl;   }
 
+   M_Open_Connexion::M_Open_Connexion() {
+      this->messageName = "M_Open_Connexion";
+      this->type = Message::OPEN_CONNEXION;
+      //versionMajor= <no default value in message spec using builtin>
+      //versionMinor= <no default value in message spec using builtin>
+   }
+
+   M_Open_Connexion::~M_Open_Connexion() {
+   }
+
+   void M_Open_Connexion::serialize(MessageBuffer& msgBuffer) {
+      //Call mother class
+      Super::serialize(msgBuffer);
+      //Specific serialization code
+      msgBuffer.write_uint32(versionMajor);
+      msgBuffer.write_uint32(versionMinor);
+   }
+
+   void M_Open_Connexion::deserialize(MessageBuffer& msgBuffer) {
+      //Call mother class
+      Super::deserialize(msgBuffer);
+      //Specific deserialization code
+      versionMajor = msgBuffer.read_uint32();
+      versionMinor = msgBuffer.read_uint32();
+   }
+
+   void M_Open_Connexion::show(std::ostream& out) {
+      out << "[M_Open_Connexion -Begin]" << std::endl;      //Call mother class
+      Super::show(out);
+      //Specific show code
+      out << " versionMajor = " << versionMajor << " "       << std::endl;
+      out << " versionMinor = " << versionMinor << " "       << std::endl;
+      out << "[M_Open_Connexion -End]" << std::endl;   }
+
    M_Close_Connexion::M_Close_Connexion() {
       this->messageName = "M_Close_Connexion";
       this->type = Message::CLOSE_CONNEXION;
@@ -4302,12 +4336,15 @@
    }
 
    Message* M_Factory::create(M_Type type) throw (RTIinternalError) {
-      Message* msg;
+      Message* msg = NULL;
 
       switch (type) {
          case Message::NOT_USED:
             throw RTIinternalError("NOT_USED message type should not be 
used!!");
             break;
+         case Message::OPEN_CONNEXION:
+            msg = new M_Open_Connexion();
+            break;
          case Message::CLOSE_CONNEXION:
             msg = new M_Close_Connexion();
             break;
@@ -4744,7 +4781,7 @@
       return msg;
    } /* end of M_Factory::create */
 
-   Message* M_Factory::receive(StreamType stream) throw (RTIinternalError) {
+   Message* M_Factory::receive(MStreamType stream) throw (RTIinternalError) {
       // FIXME This is not thread safe
       static MessageBuffer msgBuffer;
       Message  msgGen;

Index: libCERTI/M_Classes.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/M_Classes.hh,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -b -r3.6 -r3.7
--- libCERTI/M_Classes.hh       8 Mar 2010 11:35:30 -0000       3.6
+++ libCERTI/M_Classes.hh       14 Mar 2010 15:35:54 -0000      3.7
@@ -1,4 +1,4 @@
-// Generated on 2010 March Mon, 08 at 09:41:07 by the CERTI message generator
+// Generated on 2010 March Sun, 14 at 16:30:18 by the CERTI message generator
 #ifndef M_CLASSES_HH
 #define M_CLASSES_HH
 // ****-**** Global System includes ****-****
@@ -45,12 +45,16 @@
    //     - by included headers (see above)
    //     - with typedef (see below [if any])
 
-   typedef SocketUN* StreamType;
+   typedef SocketUN* MStreamType;
 
    typedef Message::Type M_Type;
+   namespace CERTI_Message {
+      static const uint32_t versionMajor = 1;
+      static const uint32_t versionMinor = 0;
 
    typedef enum CERTI_Message_MessageType {
       NOT_USED = 0, 
+         M_OPEN_CONNEXION, 
       M_CLOSE_CONNEXION, 
       M_CREATE_FEDERATION_EXECUTION, 
       M_DESTROY_FEDERATION_EXECUTION, 
@@ -196,6 +200,7 @@
       M_TICK_REQUEST_STOP, 
       LAST 
    } CERTI_Message_MessageType_t; //end of enum CERTI_Message_MessageType 
+   }
    // The EventRetraction is not inheriting from base "Message"
    // this is a plain message which may be used as field
    // in messages merging from "Message". As such
@@ -220,6 +225,26 @@
          uint64_t SN;
       private:
    };
+   // Connexion initialization message
+   class CERTI_EXPORT M_Open_Connexion : public Message {
+      public:
+         typedef Message Super;
+         M_Open_Connexion();
+         virtual ~M_Open_Connexion();
+         virtual void serialize(MessageBuffer& msgBuffer);
+         virtual void deserialize(MessageBuffer& msgBuffer);
+         // specific Getter(s)/Setter(s)
+         const uint32_t& getVersionMajor() const {return versionMajor;}
+         void setVersionMajor(const uint32_t& newVersionMajor) 
{versionMajor=newVersionMajor;}
+         const uint32_t& getVersionMinor() const {return versionMinor;}
+         void setVersionMinor(const uint32_t& newVersionMinor) 
{versionMinor=newVersionMinor;}
+         // the show method
+         virtual void show(std::ostream& out);
+      protected:
+         uint32_t versionMajor;
+         uint32_t versionMinor;
+      private:
+   };
    // Closing connexion message
    class CERTI_EXPORT M_Close_Connexion : public Message {
       public:
@@ -2827,7 +2852,7 @@
    class CERTI_EXPORT M_Factory {
       public:
          static Message* create(M_Type type) throw (RTIinternalError);
-         static Message* receive(StreamType stream) throw (RTIinternalError);
+         static Message* receive(MStreamType stream) throw (RTIinternalError);
       protected:
       private:
    };

Index: libCERTI/Message.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Message.hh,v
retrieving revision 3.61
retrieving revision 3.62
diff -u -b -r3.61 -r3.62
--- libCERTI/Message.hh 7 Mar 2010 18:23:39 -0000       3.61
+++ libCERTI/Message.hh 14 Mar 2010 15:35:54 -0000      3.62
@@ -45,6 +45,7 @@
 
     enum Type {
         NOT_USED = 0,
+        OPEN_CONNEXION,
         CLOSE_CONNEXION,
 
         // gestion federation

Index: libRTI/RTIambassador.cc
===================================================================
RCS file: /sources/certi/certi/libRTI/RTIambassador.cc,v
retrieving revision 3.114
retrieving revision 3.115
diff -u -b -r3.114 -r3.115
--- libRTI/RTIambassador.cc     7 Mar 2010 18:23:39 -0000       3.114
+++ libRTI/RTIambassador.cc     14 Mar 2010 15:35:54 -0000      3.115
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: RTIambassador.cc,v 3.114 2010/03/07 18:23:39 erk Exp $
+// $Id: RTIambassador.cc,v 3.115 2010/03/14 15:35:54 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include "RTI.hh"
@@ -322,6 +322,13 @@
        }
 #endif
 
+       M_Open_Connexion req, rep ;
+       req.setVersionMajor(CERTI_Message::versionMajor);
+       req.setVersionMinor(CERTI_Message::versionMinor);
+
+       G.Out(pdGendoc,"        ====>executeService OPEN_CONNEXION");
+       privateRefs->executeService(&req, &rep);
+
        G.Out(pdGendoc,"exit  RTIambassador::RTIambassador");
 }
 
@@ -2981,4 +2988,4 @@
        privateRefs->executeService(&req, &rep);
                }
 
-// $Id: RTIambassador.cc,v 3.114 2010/03/07 18:23:39 erk Exp $
+// $Id: RTIambassador.cc,v 3.115 2010/03/14 15:35:54 gotthardp Exp $

Index: scripts/CERTI_Message.msg
===================================================================
RCS file: /sources/certi/certi/scripts/CERTI_Message.msg,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- scripts/CERTI_Message.msg   11 Mar 2010 10:38:01 -0000      1.15
+++ scripts/CERTI_Message.msg   14 Mar 2010 15:35:54 -0000      1.16
@@ -23,6 +23,7 @@
 // ----------------------------------------------------------------------------
 // The messages related classes will be placed in the certi package
 package certi
+version 1.0
 
 // Message is the base class for
 // message exchanged between RTIA and Federate (libRTI) AKA CERTI Message. 
@@ -163,6 +164,12 @@
     required uint64         SN              {default = 0}
 }        
 
+// Connexion initialization message
+message M_Open_Connexion : merge Message {
+    required uint32 versionMajor
+    required uint32 versionMinor
+}
+
 // Closing connexion message
 message M_Close_Connexion : merge Message {
 }

Index: scripts/CERTI_NetworkMessage.msg
===================================================================
RCS file: /sources/certi/certi/scripts/CERTI_NetworkMessage.msg,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- scripts/CERTI_NetworkMessage.msg    11 Mar 2010 10:39:18 -0000      1.16
+++ scripts/CERTI_NetworkMessage.msg    14 Mar 2010 15:35:54 -0000      1.17
@@ -23,6 +23,7 @@
 // ----------------------------------------------------------------------------
 // The messages related classes will be placed in the certi package
 package certi
+version 1.0
 
 // Network message is the base class
 // for message exchanged between RTIA and RTIG

Index: scripts/GenMsgAST.py
===================================================================
RCS file: /sources/certi/certi/scripts/GenMsgAST.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- scripts/GenMsgAST.py        8 Mar 2010 12:52:11 -0000       1.5
+++ scripts/GenMsgAST.py        14 Mar 2010 15:35:54 -0000      1.6
@@ -17,7 +17,7 @@
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ## USA
 ##
-## $Id: GenMsgAST.py,v 1.5 2010/03/08 12:52:11 erk Exp $
+## $Id: GenMsgAST.py,v 1.6 2010/03/14 15:35:54 gotthardp Exp $
 ## ----------------------------------------------------------------------------
 
 """
@@ -101,6 +101,7 @@
     def __init__(self,name):
         super(MessageAST,self).__init__(name=name)
         self.__package            = None
+        self.__version            = None
         self.__factory            = None
         self.__nativeTypes        = []
         self.__messageTypes       = []
@@ -134,6 +135,15 @@
     # pythonic getter/setter using properties   
     package = property(fget=__getPackage,fset=__setPackage,fdel=None,doc=None)
 
+    def hasVersion(self):
+        return self.__version != None
+    def __getVersion(self):
+        return self.__version
+    def __setVersion(self,version):
+        self.__version = version
+    # pythonic getter/setter using properties   
+    version = property(fget=__getVersion,fset=__setVersion,fdel=None,doc=None)
+
     def hasFactory(self):
         return self.__factory != None
     def __getFactory(self):
@@ -186,6 +196,8 @@
                 self.addMessageType(any)
             elif isinstance(any,Package):
                 self.package = any
+            elif isinstance(any,Version):
+                self.version = any
             elif isinstance(any,Factory):
                 self.factory = any
             # Handle comment block preceding other AST element
@@ -294,6 +306,20 @@
     def __repr__(self):
         return "package %s" % self.name
 
+class Version(ASTElement):
+    """
+    Represents a version number.
+    
+    A C{Version} is a simple C{ASTElement} whose
+    name is a C{string}.
+    """
+    def __init__(self,number):
+        super(Version,self).__init__(name="Version")
+        self.number = number
+          
+    def __repr__(self):
+        return "version %d.%d" % self.number
+
 class Factory(ASTElement):
     """
     Represents a factory.

Index: scripts/GenMsgCXX.py
===================================================================
RCS file: /sources/certi/certi/scripts/GenMsgCXX.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- scripts/GenMsgCXX.py        14 Mar 2010 15:29:12 -0000      1.8
+++ scripts/GenMsgCXX.py        14 Mar 2010 15:35:54 -0000      1.9
@@ -17,7 +17,7 @@
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ## USA
 ##
-## $Id: GenMsgCXX.py,v 1.8 2010/03/14 15:29:12 gotthardp Exp $
+## $Id: GenMsgCXX.py,v 1.9 2010/03/14 15:35:54 gotthardp Exp $
 ## ----------------------------------------------------------------------------
 
 """
@@ -286,12 +286,21 @@
                            stream.write(self.getIndent()+stmt+"\n")
                            self.typedefed[stmt]=1                              
      
             
-            # Generate enum
-            lastname = ""
             # Put enum in a namespace in order to avoid conflict
             stream.write(self.getIndent())
             stream.write("namespace %s {\n" % self.AST.name.split(".")[0])
             self.indent()
+
+            # Generate version
+            if self.AST.hasVersion():
+                major,minor = self.AST.version.number
+                stream.write(self.getIndent())
+                stream.write("static const uint32_t versionMajor = %d;\n" % 
major)
+                stream.write(self.getIndent())
+                stream.write("static const uint32_t versionMinor = %d;\n" % 
minor)
+
+            # Generate enum
+            lastname = ""
             for enum in self.AST.enums:            
                 self.writeComment(stream, enum)
                 stream.write(self.getIndent())

Index: scripts/GenerateMessages.py
===================================================================
RCS file: /sources/certi/certi/scripts/GenerateMessages.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- scripts/GenerateMessages.py 8 Mar 2010 11:34:54 -0000       1.35
+++ scripts/GenerateMessages.py 14 Mar 2010 15:35:54 -0000      1.36
@@ -19,7 +19,7 @@
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ## USA
 ##
-## $Id: GenerateMessages.py,v 1.35 2010/03/08 11:34:54 erk Exp $
+## $Id: GenerateMessages.py,v 1.36 2010/03/14 15:35:54 gotthardp Exp $
 ## ----------------------------------------------------------------------------
 
 """
@@ -137,6 +137,7 @@
 # reserved keywords
 reserved = {
    'package'        : 'PACKAGE',
+   'version'        : 'VERSION',
    'factory'        : 'FACTORY',
    'factoryCreator' : 'FACTORY_CREATOR',
    'factoryReceiver': 'FACTORY_RECEIVER',   
@@ -275,6 +276,7 @@
 def p_statement(p):
     '''statement : comment_block
                  | package
+                 | version
                  | factory
                  | message                 
                  | native                 
@@ -303,6 +305,10 @@
     else:
         p[0]=p[1]+"."+p[3]
 
+def p_version(p):
+    '''version : VERSION INTEGER_VALUE PERIOD INTEGER_VALUE'''
+    p[0]=GenMsgAST.Version((p[2],p[4]))
+
 def p_factory(p):
     '''factory : FACTORY ID LBRACE factory_creator factory_receiver RBRACE'''
     p[0] = GenMsgAST.Factory(p[2],p[4],p[5])




reply via email to

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