certi-cvs
[Top][All Lists]
Advanced

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

[certi-cvs] certi RTIA/ObjectManagement.cc RTIA/RTIA_federa...


From: certi-cvs
Subject: [certi-cvs] certi RTIA/ObjectManagement.cc RTIA/RTIA_federa...
Date: Tue, 24 Jun 2008 08:56:50 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     ROUSSELOT <rousse>      08/06/24 08:56:49

Modified files:
        RTIA           : ObjectManagement.cc RTIA_federate.cc 
        include        : certi.hh 
        libCERTI       : Interaction.cc Message.cc Message.hh 
                         Message_R.cc Message_W.cc NM_Classes.cc 
                         NetworkMessage.cc NetworkMessage.hh 
                         ObjectClass.cc ObjectClassBroadcastList.cc 
                         SocketTCP.hh SocketUN.hh 
        libRTI         : RTIambassador.cc 

Log message:
        #23329 continued : MAX_BYTES_PER_VALUE suppressed

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/ObjectManagement.cc?cvsroot=certi&r1=3.49&r2=3.50
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA_federate.cc?cvsroot=certi&r1=3.84&r2=3.85
http://cvs.savannah.gnu.org/viewcvs/certi/include/certi.hh?cvsroot=certi&r1=3.30&r2=3.31
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Interaction.cc?cvsroot=certi&r1=3.39&r2=3.40
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Message.cc?cvsroot=certi&r1=3.57&r2=3.58
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Message.hh?cvsroot=certi&r1=3.48&r2=3.49
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Message_R.cc?cvsroot=certi&r1=3.28&r2=3.29
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Message_W.cc?cvsroot=certi&r1=3.33&r2=3.34
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/NM_Classes.cc?cvsroot=certi&r1=3.10&r2=3.11
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/NetworkMessage.cc?cvsroot=certi&r1=3.35&r2=3.36
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/NetworkMessage.hh?cvsroot=certi&r1=3.39&r2=3.40
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.cc?cvsroot=certi&r1=3.51&r2=3.52
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassBroadcastList.cc?cvsroot=certi&r1=3.22&r2=3.23
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketTCP.hh?cvsroot=certi&r1=3.20&r2=3.21
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketUN.hh?cvsroot=certi&r1=3.15&r2=3.16
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/RTIambassador.cc?cvsroot=certi&r1=3.88&r2=3.89

Patches:
Index: RTIA/ObjectManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/ObjectManagement.cc,v
retrieving revision 3.49
retrieving revision 3.50
diff -u -b -r3.49 -r3.50
--- RTIA/ObjectManagement.cc    12 Jun 2008 07:39:51 -0000      3.49
+++ RTIA/ObjectManagement.cc    24 Jun 2008 08:56:48 -0000      3.50
@@ -135,7 +135,9 @@
 
        for (i = 0 ; i < attribArraySize ; i++) {
            req.handleArray[i] = attribArray[i] ;
-               req.setValue(i, valueArray[i].value, valueArray[i].length);
+            char *tempValue = new char[valueArray[i].length] ;
+            memcpy(tempValue,valueArray[i].value,valueArray[i].length) ;
+            req.setValue(i, tempValue, valueArray[i].length);       
        } 
 
        req.setLabel(theTag);
@@ -182,6 +184,7 @@
     NM_Update_Attribute_Values req;
     int i ;
 
+    G.Out(pdGendoc,"enter ObjectManagement::updateAttributeValues without 
time");
     // Building request (req NetworkMessage)    
     req.federation = fm->_numero_federation ;
     req.federate = fm->federate ;
@@ -193,7 +196,9 @@
 
     for (i = 0 ; i < attribArraySize ; i++) {
         req.handleArray[i] = attribArray[i] ;
-        req.setValue(i, valueArray[i].value, valueArray[i].length);
+        char *tempValue = new char[valueArray[i].length] ;
+        memcpy(tempValue,valueArray[i].value,valueArray[i].length) ;
+        req.setValue(i, tempValue, valueArray[i].length);       
     }
 
     req.setLabel(theTag);
@@ -202,7 +207,7 @@
     std::auto_ptr<NetworkMessage> rep(comm->waitMessage(req.getType(), 
req.federate));
 
     e = rep->exception ;
-
+    G.Out(pdGendoc,"exit  ObjectManagement::updateAttributeValues without 
time");
 }
 
 // ----------------------------------------------------------------------------
@@ -322,7 +327,9 @@
 
        for (int i=0 ; i<paramArraySize ; i++) {
                req.handleArray[i] = paramArray[i] ;
-               req.setValue(i, valueArray[i].value, valueArray[i].length);
+                char *tempValue = new char[valueArray[i].length] ;
+                memcpy(tempValue,valueArray[i].value,valueArray[i].length) ;
+               req.setValue(i, tempValue, valueArray[i].length);
        }
 
        req.setLabel(theTag);
@@ -371,7 +378,9 @@
 
     for (int i=0 ; i<paramArraySize ; i++) {
        req.handleArray[i] = paramArray[i] ;
-       req.setValue(i, valueArray[i].value, valueArray[i].length);
+                char *tempValue = new char[valueArray[i].length] ;
+                memcpy(tempValue,valueArray[i].value,valueArray[i].length) ;
+               req.setValue(i, tempValue, valueArray[i].length) ;
     }
 
     req.setLabel(theTag);

Index: RTIA/RTIA_federate.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_federate.cc,v
retrieving revision 3.84
retrieving revision 3.85
diff -u -b -r3.84 -r3.85
--- RTIA/RTIA_federate.cc       13 Jun 2008 10:55:13 -0000      3.84
+++ RTIA/RTIA_federate.cc       24 Jun 2008 08:56:48 -0000      3.85
@@ -395,9 +395,8 @@
       }
 
       case Message::UPDATE_ATTRIBUTE_VALUES: {
-
-          std::vector <ValueLengthPair> ValueArray = req->getValueArray();
-
+          std::vector <ValueLengthPair> ValueArrayTemp ;
+          ValueArrayTemp = req->getValueArray();
           try {
               if (req->getBoolean() )
                   {
@@ -406,7 +405,7 @@
                   rep.setEventRetraction(
                  om->updateAttributeValues(req->getObject(),
                                             req->handleArray,
-                                            ValueArray,
+                                            ValueArrayTemp,
                                             req->handleArraySize,
                                             req->getFederationTime(),
                                             req->getTag(),
@@ -418,16 +417,16 @@
                                 "UpdateAttribValues without TIMESTAMP.");
                  om->updateAttributeValues(req->getObject(),
                                             req->handleArray,
-                                            ValueArray,
+                                            ValueArrayTemp,
                                             req->handleArraySize,
                                             req->getTag(),
                                             e);
                   }
               // Don't forget boolean value for the answer
               rep.setBoolean(req->getBoolean()) ;
-              ValueArray.empty() ;
+              ValueArrayTemp.empty() ;
           } catch (Exception *e) {
-              ValueArray.empty() ;
+              ValueArrayTemp.empty() ;
               throw e ;
           }
       }
@@ -435,7 +434,7 @@
 
       case Message::SEND_INTERACTION: {
 
-          std::vector <ParameterLengthPair> ValueArray = req->getValueArray();
+          std::vector <ParameterLengthPair> ValueArrayTemp = 
req->getValueArray();
           G.Out(pdGendoc,"S_I into RTIA::chooseFederateProcessing") ;
           try {
               if (req->getBoolean() )
@@ -445,7 +444,7 @@
                   rep.setEventRetraction(
                       om->sendInteraction(req->getInteractionClass(),
                                       req->handleArray,
-                                      ValueArray,
+                                      ValueArrayTemp,
                                       req->handleArraySize,
                                       req->getFederationTime(),
                                       req->getTag(),
@@ -458,15 +457,15 @@
    "Receiving Message from Federate, type SendInteraction without TIMESTAMP.");
                       om->sendInteraction(req->getInteractionClass(),
                                       req->handleArray,
-                                      ValueArray,
+                                      ValueArrayTemp,
                                       req->handleArraySize,
                                       req->getTag(),
                                      req->getRegion(),
                                       e);
                   }
-              ValueArray.empty();
+              ValueArrayTemp.empty();
           } catch (Exception *e) {
-              ValueArray.empty();
+              ValueArrayTemp.empty();
               throw e ;
           }
       }

Index: include/certi.hh
===================================================================
RCS file: /sources/certi/certi/include/certi.hh,v
retrieving revision 3.30
retrieving revision 3.31
diff -u -b -r3.30 -r3.31
--- include/certi.hh    16 Jun 2008 09:03:24 -0000      3.30
+++ include/certi.hh    24 Jun 2008 08:56:48 -0000      3.31
@@ -16,7 +16,7 @@
 // License along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: certi.hh,v 3.30 2008/06/16 09:03:24 rousse Exp $
+// $Id: certi.hh,v 3.31 2008/06/24 08:56:48 rousse Exp $
 // ----------------------------------------------------------------------------
 #include <vector>
 
@@ -93,7 +93,7 @@
    
 // Deprecated HLA macros still in use
 // Will be suppressed asap
-#define MAX_BYTES_PER_VALUE 500
+//#define MAX_BYTES_PER_VALUE 500
 //#define MAX_FEDERATE_NAME_LENGTH 64
 //#undef MAX_USER_TAG_LENGTH
 //#define MAX_USER_TAG_LENGTH 64
@@ -237,8 +237,8 @@
 RTI_EXCEPT(NetworkError)
 
 // Deprecated HLA types still in use
-typedef char AttributeValue[MAX_BYTES_PER_VALUE + 1] ;
-//typedef std::vector<char> AttributeValue ;
+//typedef char AttributeValue[MAX_BYTES_PER_VALUE + 1] ;
+typedef char *AttributeValue ;
 
 //  typedef std::vector<char>  AttributeValue;
 typedef RTI::Double FederationTime ;
@@ -384,4 +384,4 @@
        (uint64_t) CERTI_INT64_CONSTANT(0xff00000000000000U)) >> 56)))
 #endif // CERTI_HH_INCLUDED
 
-// $Id: certi.hh,v 3.30 2008/06/16 09:03:24 rousse Exp $
+// $Id: certi.hh,v 3.31 2008/06/24 08:56:48 rousse Exp $

Index: libCERTI/Interaction.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Interaction.cc,v
retrieving revision 3.39
retrieving revision 3.40
diff -u -b -r3.39 -r3.40
--- libCERTI/Interaction.cc     11 Jun 2008 15:19:21 -0000      3.39
+++ libCERTI/Interaction.cc     24 Jun 2008 08:56:49 -0000      3.40
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Interaction.cc,v 3.39 2008/06/11 15:19:21 rousse Exp $
+// $Id: Interaction.cc,v 3.40 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -419,6 +419,7 @@
 
         answer->handleArraySize = list_size ;
         answer->handleArray.resize(list_size) ;
+        answer->sizeValueArray(list_size);
         for (int i = 0 ; i < list_size ; i++) {
             answer->handleArray[i] = parameter_list[i] ;
             answer->setValue(i, value_list[i].value, value_list[i].length);
@@ -551,4 +552,4 @@
 
 } // namespace certi
 
-// $Id: Interaction.cc,v 3.39 2008/06/11 15:19:21 rousse Exp $
+// $Id: Interaction.cc,v 3.40 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/Message.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Message.cc,v
retrieving revision 3.57
retrieving revision 3.58
diff -u -b -r3.57 -r3.58
--- libCERTI/Message.cc 12 Jun 2008 07:39:50 -0000      3.57
+++ libCERTI/Message.cc 24 Jun 2008 08:56:49 -0000      3.58
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <cstdio>
 #include <cstring>
+#include <assert.h>
 
 using std::vector ;
 
@@ -74,7 +75,7 @@
     @param Rank valueArray rank
     @param length byte number of Value tooken from valueArray[Rank] (modified)
     @param Value Value tooken from valueArray[Rank]
-           Value is managed as a set of bytes
+           Value is managed as an address to a set of bytes
     Note : if Value is not present, Value is created and its address is 
returned
            by getValue
     getValue allows Value as a set of bytes because length (parameter 2) is 
known
@@ -85,8 +86,8 @@
 {
     // Pre-Checking
 
-    if ((Rank < 0) || ((Rank+1) > (int)valueArray.size()) )
-        throw RTIinternalError("Bad Rank in Message.");
+    if ((Rank < 0) )
+        throw RTIinternalError("(getValue) Bad Rank in Message.");
 
     // Getting Value
     // First, the length of the Value
@@ -95,14 +96,15 @@
     if (Value != NULL)
         // Value exists, we copy it with memcpy instead of strcpy
         {
-        memcpy(Value,valueArray[Rank].value, *length) ;     
+        memcpy(Value,(char *)*(valueArray[Rank].value), *length) ;     
         return NULL ;
         }
     else
         // Value doesn't exists, so create it then copy
         {
-        char *Value = new char [*length] ;
-        memcpy(Value,valueArray[Rank].value, *length) ;
+        char *TempValue = new char [*length] ;
+        memcpy(TempValue,(char *)*(valueArray[Rank].value), *length) ;
+        Value = TempValue ;
         return Value ;
         }
 }
@@ -113,19 +115,20 @@
 std::vector <ParameterLengthPair>
 Message::getValueArray()
 {
+    G.Out(pdGendoc,"enter Message::getValueArray");
     int i ;
-    unsigned long length ;
 
     std::vector <ParameterLengthPair> NewValueArray ;
-
     NewValueArray.resize(handleArraySize) ;
 
     for (i = 0 ; i < handleArraySize ; i++)
         {
-        getValue(i, &length, NewValueArray[i].value);
-        NewValueArray[i].length = length ;
+        NewValueArray[i].length = valueArray[i].length ;
+        NewValueArray[i].value = new char[NewValueArray[i].length] ;
+        
memcpy(&(NewValueArray[i].value[0]),valueArray[i].value,NewValueArray[i].length);
         }
 
+    G.Out(pdGendoc,"return Message::getValueArray");
     return NewValueArray ;
 }
 
@@ -379,9 +382,11 @@
 
     for (int i = 0 ; i < handleArraySize ; i++)
         {
-        value = getValue(i, &length);
+        length = valueArray[i].length ;
+        value = new char[length] ;
+        memcpy(value,valueArray[i].value,length);
         ahvps->add(handleArray[i], value, length);
-        delete[] value;
+        //delete[] value;
         }
 
     return ahvps ;
@@ -394,9 +399,12 @@
 void
 Message::setAHVPS(const RTI::AttributeHandleValuePairSet &the_attributes)
 {
+    G.Out(pdGendoc,"enter Message::setAHVPS");
     ULong length ;
 
     unsigned long size ;
+    char *valuebuf=NULL;
+
     size = the_attributes.size() ;
     handleArraySize = size ;
     handleArray.resize(handleArraySize);
@@ -408,15 +416,17 @@
         handleArray[i] = the_attributes.getHandle(size-1-i);
         // value length extracted from the_attributes
         length = the_attributes.getValueLength(size-1-i) ;
-        // then we can create value
-        char *value = new char[length] ;
-        // copying into value
-        the_attributes.getValue(size-1-i,value,length) ;
-
-        // value and its length are stored into valueArray[i]
-        setValue(i, value, length);
-        delete[] value;
+
+        // copying into valuebuf created by getValue
+        valuebuf = new char[length] ;
+        the_attributes.getValue(size-1-i,valuebuf,length) ;
+
+        // valuebuf address and its length are stored into valueArray[i]
+        valueArray[i].length = length ;
+        valueArray[i].value = valuebuf ;
+
     }
+    G.Out(pdGendoc,"exit  Message::setAHVPS");
 }
 
 // ----------------------------------------------------------------------------
@@ -431,7 +441,9 @@
 
     for (int i = 0 ; i < handleArraySize ; i++)
         {
-        value = getValue(i, &length);
+        length = valueArray[i].length ;
+        value = new char[length] ;
+        memcpy(value,valueArray[i].value,length);
         phvps->add(handleArray[i], value, length);
         }
 
@@ -442,22 +454,32 @@
 void
 Message::setPHVPS(const RTI::ParameterHandleValuePairSet &the_parameters)
 {
+    G.Out(pdGendoc,"enter Message::setPHVPS");
     ULong length ;
 
     unsigned long size ;
+    char *valuebuf=NULL;
+
     size = the_parameters.size() ;
     handleArraySize = size ;
     handleArray.resize(handleArraySize);
+    valueArray.resize(size) ;
 
     for (unsigned long i = 0 ; i < size ; i++)
         {
+        // handle stored into handleArray[i]
         handleArray[i] = the_parameters.getHandle(size-1-i);
+        // value length extracted from the_parameters
         length = the_parameters.getValueLength(size-1-i) ;
-        char *value = new char[length] ;
-        the_parameters.getValue(size-1-i, value, length) ;
-        setValue(i, value, length);
-        delete[] value;
+        // copying into valuebuf created by getValue
+        valuebuf = new char[length] ;
+        the_parameters.getValue(size-1-i, valuebuf, length) ;
+        // valuebuf address and its length are stored into valueArray(i]
+        valueArray[i].length = length ;
+        valueArray[i].value = valuebuf ;
+
         }
+    G.Out(pdGendoc,"exit  Message::setPHVPS");
 }
 
 // ----------------------------------------------------------------------------
@@ -473,34 +495,52 @@
 }
 
 // ----------------------------------------------------------------------------
+// setAttributes
+// store attributes into handleArray
+// store values     into valueArray
 void
 Message::setAttributes(std::vector <AttributeHandle> &the_attributes,
                        std::vector <ValueLengthPair> &the_values,
                        ushort the_size)
 {
+    G.Out(pdGendoc,"enter Message::setAttributes");
+    char *tempValue ;
     handleArraySize = the_size ;
     handleArray.resize(handleArraySize);
     valueArray.resize(the_size) ;
 
     for (int i = 0 ; i < the_size ; i++) {
+        // attributes into handleArray
         handleArray[i] = the_attributes[i] ;
-        setValue(i, the_values[i].value,the_values[i].length ) ;
+        // values     into valueArray
+        tempValue = new char[the_values[i].length] ;
+        memcpy(tempValue,the_values[i].value,the_values[i].length ) ;
+        setValue(i, tempValue,the_values[i].length ) ;
     }
+    G.Out(pdGendoc,"exit  Message::setAttributes");
 }
 
 // ----------------------------------------------------------------------------
+// setParameters
+// store parameters into handleArray
+// store values     into valueArray
 void
 Message::setParameters(std::vector <ParameterHandle> & the_parameters,
                        std::vector <ParameterLengthPair> & the_values,
                        ushort the_size)
 
 {
+    char *tempValue ;
     handleArraySize = the_size ;
     handleArray.resize(handleArraySize);
     valueArray.resize(the_size) ;
 
     for (int i = 0 ; i < the_size ; i++) {
+        // parameters into handleArray
         handleArray[i] = the_parameters[i] ;
+        // values     into valueArray
+        tempValue = new char[the_values[i].length] ;
+        memcpy(tempValue,the_values[i].value,the_values[i].length ) ;
         setValue(i, the_values[i].value, the_values[i].length);
     }
 }
@@ -535,28 +575,26 @@
 
 // ----------------------------------------------------------------------------
 // setValue
-//
+// Store Value into valueArray[Rank)
 void
 Message::setValue(int Rank, const char *Value, unsigned long length)
     throw (RTIinternalError)
 {
 
     // Pre-Checking
-    // Yes, I know, but common error, this may help user...
-  if ( length > MAX_BYTES_PER_VALUE )
-     std :: cout << "Message::setValue too high length = " << length << std :: 
endl;
-
-    if ((Value == NULL) || (length > MAX_BYTES_PER_VALUE))
-        throw RTIinternalError("Bad Value for message.");
-
-    if ((Rank < 0))
-        throw RTIinternalError("Bad Rank for message.");
-    if ( (Rank+1) > (int)valueArray.size() )
-       valueArray.resize(Rank+1) ;
+
+    if ((Value == NULL))
+        throw RTIinternalError("Bad Value (NULL) for message.");
+
+    if ((Rank < 0) )
+        throw RTIinternalError("(setValue) Bad Rank for message.");
+
     // Setting Value
-    // First we store the length, then copy with memcpy instead of strcpy
+    // First we store the value length
     valueArray[Rank].length = length ;
-    memcpy(valueArray[Rank].value, Value, length);
+    
+    // then copy Value address into valueArray
+    valueArray[Rank].value = (char *)Value ;
 }
 
 // ----------------------------------------------------------------------------
@@ -625,7 +663,9 @@
     for (i=0 ; i < handleArraySize ; i++)
         {
         valueArray[i].length = msg.valueArray[i].length ;
-        memcpy(valueArray[i].value, msg.valueArray[i].value, 
msg.valueArray[i].length );
+        char * TempValue = new char[valueArray[i].length] ;
+        memcpy(TempValue, (char *)*(msg.valueArray[i].value), 
msg.valueArray[i].length );
+        valueArray[i].value=TempValue ;
         }
 
     FEDid = msg.FEDid ;
@@ -675,4 +715,26 @@
     // printf(" ordering %d:\n", ordering);
 }
 
+// ----------------------------------------------------------------------------
+void
+Message::displayvalueArray(char *titre)
+{
+printf("(%s) valueArray size=%d\n",titre,(int)valueArray.size());
+for (int i=0; i<(int)valueArray.size();i++)
+   {
+   printf("%d : length=%d : value=",i,(int)(valueArray[i].length));
+   for (int k=0; k<(int)valueArray[i].length ;k++)
+      {
+      if (isprint(valueArray[i].value[k]) == 0 )
+         {
+         printf(" %x",valueArray[i].value[k]);
+         }
+      else
+         {
+         printf("%c",valueArray[i].value[k]);
+         }
+      }
+printf("\n");
+   }
+}
 } // namespace certi

Index: libCERTI/Message.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Message.hh,v
retrieving revision 3.48
retrieving revision 3.49
diff -u -b -r3.48 -r3.49
--- libCERTI/Message.hh 11 Jun 2008 15:19:21 -0000      3.48
+++ libCERTI/Message.hh 24 Jun 2008 08:56:49 -0000      3.49
@@ -281,7 +281,7 @@
     // Parameter 1 : Rank (int) : valueArray rank
     // Parameter 2 :length (unsigned long *) : byte number of Value tooken
     //              from valueArray[Rank]
-    // Parameter 3 : Value (char *) : Value tooken from valueArray[Rank]
+    // Parameter 3 : Value (char *) : Value address tooken from 
valueArray[Rank]
     //               Value is managed as a set of bytes
     // Note : if parametre 3 not present, Value is created and its address is 
returned
     //        by getValue
@@ -405,6 +405,9 @@
 
     std::string getFEDid() const { return FEDid ; };
     void setFEDid(std::string FEDid);
+
+        void displayvalueArray(char *);
+
     // Public attributes
     Type type ;
 

Index: libCERTI/Message_R.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Message_R.cc,v
retrieving revision 3.28
retrieving revision 3.29
diff -u -b -r3.28 -r3.29
--- libCERTI/Message_R.cc       11 Jun 2008 15:19:21 -0000      3.28
+++ libCERTI/Message_R.cc       24 Jun 2008 08:56:49 -0000      3.29
@@ -17,7 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Message_R.cc,v 3.28 2008/06/11 15:19:21 rousse Exp $
+// $Id: Message_R.cc,v 3.29 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -42,7 +42,7 @@
         */
        msgBuffer.reset();
        /* 1- Read 'reserved bytes' header from socket */
-       //D.Out(pdDebug,"Reading %d 'reserved' bytes",msgBuffer.reservedBytes);
+       D.Out(pdDebug,"Reading %d 'reserved' bytes",msgBuffer.reservedBytes);
        socket->receive(static_cast<const unsigned char *>(msgBuffer(0)), 
msgBuffer.reservedBytes);     
        //msgBuffer.show(msgBuffer(0),5);fflush(stdout);
        /* 2- update (assume) complete message size from reserved bytes */
@@ -610,9 +610,10 @@
     valueArray.resize(handleArraySize) ;
     for (int i = 0 ; i < handleArraySize ; i ++)
         {
-
         valueArray[i].length = msgBuffer.read_int64() ;
-        msgBuffer.read_bytes((char *) valueArray[i].value, 
valueArray[i].length);
+        char *TempValue = new char[valueArray[i].length] ;
+        msgBuffer.read_bytes((char *) TempValue, valueArray[i].length);
+        valueArray[i].value=TempValue;
         }
 }
 
@@ -626,4 +627,4 @@
 
 } // namespace certi
 
-// $Id: Message_R.cc,v 3.28 2008/06/11 15:19:21 rousse Exp $
+// $Id: Message_R.cc,v 3.29 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/Message_W.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Message_W.cc,v
retrieving revision 3.33
retrieving revision 3.34
diff -u -b -r3.33 -r3.34
--- libCERTI/Message_W.cc       11 Jun 2008 15:19:21 -0000      3.33
+++ libCERTI/Message_W.cc       24 Jun 2008 08:56:49 -0000      3.34
@@ -17,7 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Message_W.cc,v 3.33 2008/06/11 15:19:21 rousse Exp $
+// $Id: Message_W.cc,v 3.34 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -577,10 +577,11 @@
     for (int i = 0 ; i < handleArraySize ; i ++)
         {
         msgBuffer.write_int64(valueArray[i].length) ;
-        msgBuffer.write_bytes(valueArray[i].value, valueArray[i].length) ;
+        assert(valueArray[i].value != 0);
+        msgBuffer.write_bytes((char *)(valueArray[i].value), 
valueArray[i].length) ;
     }
 }
 
 } // namespace certi
 
-// $Id: Message_W.cc,v 3.33 2008/06/11 15:19:21 rousse Exp $
+// $Id: Message_W.cc,v 3.34 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/NM_Classes.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/NM_Classes.cc,v
retrieving revision 3.10
retrieving revision 3.11
diff -u -b -r3.10 -r3.11
--- libCERTI/NM_Classes.cc      11 Jun 2008 15:19:21 -0000      3.10
+++ libCERTI/NM_Classes.cc      24 Jun 2008 08:56:49 -0000      3.11
@@ -19,7 +19,7 @@
 // ----------------------------------------------------------------------------
 
 #include "NM_Classes.hh"
-
+#include <assert.h>
 namespace certi {
 
 NetworkMessage* NM_Factory::create(NetworkMessage::Message_T type) throw 
(RTIinternalError) {
@@ -988,7 +988,9 @@
         ValueArray.resize(handleArraySize) ;   
        for (i = 0 ; i < handleArraySize ; i ++) {
                ValueArray[i].length = msgBuffer.read_int32();
-               msgBuffer.read_bytes(ValueArray[i].value, 
ValueArray[i].length);                
+                char *tempValue = new char[ValueArray[i].length] ;
+               msgBuffer.read_bytes(tempValue, ValueArray[i].length);
+                ValueArray[i].value = tempValue ;              
        }
 } /* end of deserialize */
 /*<END>---------- Update_Attribute_Values ------------<END>*/
@@ -1021,7 +1023,7 @@
        /* the value pre-encoded by the user (HLA 1.3) */
        for (i = 0 ; i < handleArraySize ; i++) {
                msgBuffer.write_int32(ValueArray[i].length) ;
-               msgBuffer.write_bytes(ValueArray[i].value, 
ValueArray[i].length);
+               msgBuffer.write_bytes((char *)ValueArray[i].value, 
ValueArray[i].length);
        }    
 } /* end of serialize */ 
 void NM_Send_Interaction::deserialize(MessageBuffer& msgBuffer) {
@@ -1034,7 +1036,9 @@
         ValueArray.resize(handleArraySize) ;
        for (i = 0 ; i < handleArraySize ; i ++) {
                ValueArray[i].length = msgBuffer.read_int32();
-               msgBuffer.read_bytes(ValueArray[i].value, ValueArray[i].length);
+                char *tempValue = new char[ValueArray[i].length] ;
+               msgBuffer.read_bytes(tempValue, ValueArray[i].length);
+                ValueArray[i].value = tempValue ;
        }
 } /* end of deserialize */
 /*<END>---------- Send_Interaction ------------<END>*/

Index: libCERTI/NetworkMessage.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/NetworkMessage.cc,v
retrieving revision 3.35
retrieving revision 3.36
diff -u -b -r3.35 -r3.36
--- libCERTI/NetworkMessage.cc  12 Jun 2008 07:39:49 -0000      3.35
+++ libCERTI/NetworkMessage.cc  24 Jun 2008 08:56:49 -0000      3.36
@@ -16,7 +16,7 @@
 // License along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: NetworkMessage.cc,v 3.35 2008/06/12 07:39:49 erk Exp $
+// $Id: NetworkMessage.cc,v 3.36 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -80,14 +80,14 @@
 
     std::vector <ValueLengthPair> NewValueArray ;
     
-    unsigned long length ;
 
     NewValueArray.resize(handleArraySize) ;
 
     for (int i = 0 ; i <handleArraySize ; i++)
         {
-        getValue(i, &length, NewValueArray[i].value);
-        NewValueArray[i].length = length ;
+        NewValueArray[i].length = ValueArray[i].length ;
+        NewValueArray[i].value = new char[NewValueArray[i].length] ;
+        
memcpy(NewValueArray[i].value,ValueArray[i].value,NewValueArray[i].length);
         }
 
     return NewValueArray ;
@@ -101,12 +101,12 @@
 
     NewValueArray.resize(handleArraySize) ;
 
-    unsigned long length ;
 
     for (int i = 0 ; i < handleArraySize ; i++)
         {
-        getValue(i, &length, NewValueArray[i].value);
-        NewValueArray[i].length = length ;
+        NewValueArray[i].length = ValueArray[i].length ;
+        NewValueArray[i].value = new char[NewValueArray[i].length] ;
+        
memcpy(NewValueArray[i].value,ValueArray[i].value,NewValueArray[i].length);
         }
 
     return NewValueArray ;
@@ -118,23 +118,25 @@
     throw (RTIinternalError)
 {
     // Pre-Checking
-    if ((Rank < 0) || (Rank >= handleArraySize))
-        throw RTIinternalError("Bad Rank in Message.");
+    if ((Rank < 0) || (Rank >= (int)ValueArray.size()))
+        throw RTIinternalError("(getValue) Bad Rank in NMessage.");
 
     // Getting Value
     // First, the length of the Value
     *length = ValueArray[Rank].length ;
+
     if (Value != NULL) 
         // Value exists, we copy it with memcpy instead of strcpy
         {
-        memcpy(Value, ValueArray[Rank].value, *length);
+        memcpy(Value, (char *)*(ValueArray[Rank].value), *length);
         return NULL ;
         }
     else
         // Value doesn't exist, so create it then copy
         {
-        char *Value = new char [*length] ;
-        memcpy(Value,ValueArray[Rank].value, *length) ;
+        char *TempValue = new char [*length] ;
+        memcpy(TempValue,(char *)*(ValueArray[Rank].value), *length) ;
+        Value = TempValue ;
         return Value ;
         }
 }
@@ -145,15 +147,14 @@
 {
     UShort AttribIndex = 0 ;
 
-    if (Rank >= handleArraySize)
-        throw RTIinternalError("Bad Rank while removing message attribute.");
+    if (Rank >= ValueArray.size())
+        throw RTIinternalError("Bad Rank while removing Nmessage attribute.");
 
     // Shift Attribute Handles and Values
     for (AttribIndex = Rank ; AttribIndex < handleArraySize - 1 ; AttribIndex 
++) {
         handleArray[AttribIndex] = handleArray[AttribIndex + 1] ;
         ValueArray[AttribIndex].length = ValueArray[AttribIndex + 1].length ;
-        memcpy(ValueArray[AttribIndex].value,ValueArray[AttribIndex + 1].value,
-               ValueArray[AttribIndex + 1].length) ;
+        ValueArray[AttribIndex].value = ValueArray[AttribIndex + 1].value ;
     }
 
     handleArraySize -- ;
@@ -165,37 +166,40 @@
 {
     UShort ParamIndex = 0 ;
 
-    if (Rank >= handleArraySize)
-        throw RTIinternalError("Bad Rank while removing message parameter.");
+    if (Rank >= ValueArray.size())
+        throw RTIinternalError("Bad Rank while removing Nmessage parameter.");
 
     // Shift Parameter Handles and Values
     for (ParamIndex = Rank ; ParamIndex < handleArraySize - 1 ; ParamIndex ++) 
{
         handleArray[ParamIndex] = handleArray[ParamIndex + 1] ;
         ValueArray[ParamIndex].length = ValueArray[ParamIndex + 1].length ;
-        memcpy(ValueArray[ParamIndex].value,ValueArray[ParamIndex + 1].value,
-               ValueArray[ParamIndex + 1].length) ;
+        ValueArray[ParamIndex].value = ValueArray[ParamIndex + 1].value ;
     }
 
     handleArraySize -- ;
 }
 
 // ----------------------------------------------------------------------------
+// Store Value into ValueArray[Rank)
 void
 NetworkMessage::setValue(int Rank, const char *Value, unsigned long length)
     throw (RTIinternalError)
 {
     // Pre-Checking
-    if ((Value == NULL) || (length > MAX_BYTES_PER_VALUE))
-        throw RTIinternalError("Bad Value for message.");
+    if (Value == NULL)
+        throw RTIinternalError("Bad Value (NULL) for Network message.");
 
-    if ((Rank < 0) || (Rank >= handleArraySize))
-        throw RTIinternalError("Bad Rank for message.");
+    if ((Rank < 0) || (Rank >= (int)ValueArray.size() ))
+        throw RTIinternalError("(setValue) Bad Rank for Nmessage.");
 
     // Setting Value
-    // First we store the length, then copy Value with memcpy instead of strcpy
-    ValueArray.resize(handleArraySize) ;
+    // First we store the length
     ValueArray[Rank].length = length ;
-    memcpy(ValueArray[Rank].value, Value, length);
+
+    // then copy Value address into ValueArray
+    char *tempValue = new char[length] ;
+    memcpy(tempValue, Value, length);
+    ValueArray[Rank].value = (char *)tempValue ;
 
 }
 
@@ -215,7 +219,27 @@
 {
 ValueArray.resize(size) ;
 }
+// ----------------------------------------------------------------------------
+void
+NetworkMessage::displayValueArray(char *titre)
+{
+printf("(%s) ValueArray size=%d\n",titre,(int)ValueArray.size());
+for (int i=0; i<(int)ValueArray.size();i++)
+   {
+   printf("%d : length=%d : value=",i,(int)(ValueArray[i].length));
+   for (int k=0; k<(int)ValueArray[i].length ;k++)
+      if (isprint(ValueArray[i].value[k]) == 0 )
+         {
+         printf(" %x",ValueArray[i].value[k]);
+         }
+      else
+         {
+         printf("%c",ValueArray[i].value[k]);
+         }
+printf("\n");
+   }
+}
 
 } // namespace certi
 
-// $Id: NetworkMessage.cc,v 3.35 2008/06/12 07:39:49 erk Exp $
+// $Id: NetworkMessage.cc,v 3.36 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/NetworkMessage.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/NetworkMessage.hh,v
retrieving revision 3.39
retrieving revision 3.40
diff -u -b -r3.39 -r3.40
--- libCERTI/NetworkMessage.hh  23 Jun 2008 13:25:04 -0000      3.39
+++ libCERTI/NetworkMessage.hh  24 Jun 2008 08:56:49 -0000      3.40
@@ -17,7 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: NetworkMessage.hh,v 3.39 2008/06/23 13:25:04 erk Exp $
+// $Id: NetworkMessage.hh,v 3.40 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef CERTI_NETWORK_MESSAGE_HH
@@ -196,6 +196,8 @@
 
        void setAHS(const std::vector <AttributeHandle> &, int);
 
+        void displayValueArray(char *);
+
        UShort number ;
 
        std::string federationName ;
@@ -354,4 +356,4 @@
 
 #endif // CERTI_NETWORK_MESSAGE_HH
 
-// $Id: NetworkMessage.hh,v 3.39 2008/06/23 13:25:04 erk Exp $
+// $Id: NetworkMessage.hh,v 3.40 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/ObjectClass.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.cc,v
retrieving revision 3.51
retrieving revision 3.52
diff -u -b -r3.51 -r3.52
--- libCERTI/ObjectClass.cc     18 Jun 2008 13:46:14 -0000      3.51
+++ libCERTI/ObjectClass.cc     24 Jun 2008 08:56:49 -0000      3.52
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClass.cc,v 3.51 2008/06/18 13:46:14 erk Exp $
+// $Id: ObjectClass.cc,v 3.52 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include  "Object.hh"
@@ -916,10 +916,14 @@
         answer->setLabel(the_tag);
         answer->handleArray.resize(the_size) ;
         answer->handleArraySize = the_size ;
+        answer->sizeValueArray(the_size) ;
 
         for (int i = 0 ; i < the_size ; i++) {
             answer->handleArray[i] = the_attributes[i] ;
-            answer->setValue(i, the_values[i].value, the_values[i].length);
+            // value recopy into answer
+            char *tempValue = new char[the_values[i].length] ;
+            memcpy(tempValue,the_values[i].value,the_values[i].length) ;
+            answer->setValue(i, tempValue, the_values[i].length);   
         }
 
         ocbList = new ObjectClassBroadcastList(answer, attributeSet.size());
@@ -979,10 +983,14 @@
 
         answer->handleArraySize = the_size ;
         answer->handleArray.resize(the_size) ;
+        answer->sizeValueArray(the_size) ;
 
         for (int i = 0 ; i < the_size ; i++) {
             answer->handleArray[i] = the_attributes[i] ;
-            answer->setValue(i, the_values[i].value, the_values[i].length);
+            // value recopy into answer
+            char *tempValue = new char[the_values[i].length] ;
+            memcpy(tempValue,the_values[i].value,the_values[i].length) ;
+            answer->setValue(i, tempValue, the_values[i].length);   
         }
 
         ocbList = new ObjectClassBroadcastList(answer, attributeSet.size());
@@ -1824,4 +1832,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClass.cc,v 3.51 2008/06/18 13:46:14 erk Exp $
+// $Id: ObjectClass.cc,v 3.52 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/ObjectClassBroadcastList.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassBroadcastList.cc,v
retrieving revision 3.22
retrieving revision 3.23
diff -u -b -r3.22 -r3.23
--- libCERTI/ObjectClassBroadcastList.cc        11 Jun 2008 15:19:22 -0000      
3.22
+++ libCERTI/ObjectClassBroadcastList.cc        24 Jun 2008 08:56:49 -0000      
3.23
@@ -19,10 +19,11 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClassBroadcastList.cc,v 3.22 2008/06/11 15:19:22 rousse Exp $
+// $Id: ObjectClassBroadcastList.cc,v 3.23 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
+#include <assert.h>
 
 #include "ObjectClassBroadcastList.hh"
 #include "PrettyDebug.hh"
@@ -83,7 +84,7 @@
     // Copy attributes that are in the bsWaiting state in Line.
     UShort currentSize ;
     AttributeHandle currentAttrib ;
-    char buffer[MAX_BYTES_PER_VALUE + 1] ;
+    char *buffer =NULL;
     unsigned long length ;
 
     reducedMessage->handleArraySize = 0 ;
@@ -97,6 +98,8 @@
             // Update number of attributes in ReducedMessage.
             currentSize = reducedMessage->handleArraySize ;
             reducedMessage->handleArraySize ++ ;
+            
reducedMessage->handleArray.resize(reducedMessage->handleArraySize);
+            reducedMessage->sizeValueArray(reducedMessage->handleArraySize);
 
             // Copy Attribute Handle.
             reducedMessage->handleArray[currentSize] = currentAttrib ;
@@ -104,8 +107,10 @@
             if (message->getType() == 
NetworkMessage::REFLECT_ATTRIBUTE_VALUES) {
                 // Copy Attribute Value.
                 message->getValue(i, &length, buffer);
-                reducedMessage->setValue(currentSize, buffer, length);
-
+                char *tempValue = new char[length] ;
+                memcpy(tempValue,buffer,length) ;
+                reducedMessage->setValue(currentSize, tempValue, length);
+                buffer = NULL ;
             }
         }
     }
@@ -396,4 +401,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClassBroadcastList.cc,v 3.22 2008/06/11 15:19:22 rousse Exp $
+// $Id: ObjectClassBroadcastList.cc,v 3.23 2008/06/24 08:56:49 rousse Exp $

Index: libCERTI/SocketTCP.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketTCP.hh,v
retrieving revision 3.20
retrieving revision 3.21
diff -u -b -r3.20 -r3.21
--- libCERTI/SocketTCP.hh       5 May 2008 09:06:52 -0000       3.20
+++ libCERTI/SocketTCP.hh       24 Jun 2008 08:56:49 -0000      3.21
@@ -31,7 +31,7 @@
 // This is the read buffer of TCP sockets. It must be at least as long
 // as the longest data ever received by a socket.
 // If the next line is commented out, no buffer will be used at all.
-#define SOCKTCP_BUFFER_LENGTH 4096
+//#define SOCKTCP_BUFFER_LENGTH 4096
 
 namespace certi {
 

Index: libCERTI/SocketUN.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketUN.hh,v
retrieving revision 3.15
retrieving revision 3.16
diff -u -b -r3.15 -r3.16
--- libCERTI/SocketUN.hh        23 Jun 2008 12:49:15 -0000      3.15
+++ libCERTI/SocketUN.hh        24 Jun 2008 08:56:49 -0000      3.16
@@ -43,7 +43,7 @@
 // This is the read buffer of UNIX sockets. It must be at least as
 // long as the longest data ever received by a socket. If the next
 // line is commented out, no buffer will be used at all.
-#define SOCKUN_BUFFER_LENGTH 4096
+//#define SOCKUN_BUFFER_LENGTH 4096
 
 /**
  * Socket Unix handling class.

Index: libRTI/RTIambassador.cc
===================================================================
RCS file: /sources/certi/certi/libRTI/RTIambassador.cc,v
retrieving revision 3.88
retrieving revision 3.89
diff -u -b -r3.88 -r3.89
--- libRTI/RTIambassador.cc     12 Jun 2008 07:39:51 -0000      3.88
+++ libRTI/RTIambassador.cc     24 Jun 2008 08:56:49 -0000      3.89
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: RTIambassador.cc,v 3.88 2008/06/12 07:39:51 erk Exp $
+// $Id: RTIambassador.cc,v 3.89 2008/06/24 08:56:49 rousse Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -1175,6 +1175,7 @@
            RestoreInProgress,
            RTIinternalError)
 {
+    G.Out(pdGendoc,"enter RTIambassador::updateAttributeValues with time");
     Message req, rep ;
 
     req.type = Message::UPDATE_ATTRIBUTE_VALUES ;
@@ -1189,7 +1190,7 @@
     req.setBoolean(true);
 
     privateRefs->executeService(&req, &rep);
-
+    G.Out(pdGendoc,"return  RTIambassador::updateAttributeValues with time");
     return rep.getEventRetraction();
 }
 
@@ -1211,6 +1212,7 @@
           RTI::ConcurrentAccessAttempted, RTI::FederateNotExecutionMember, 
           RTI::AttributeNotOwned, RTI::AttributeNotDefined, 
RTI::ObjectNotKnown)
 {
+    G.Out(pdGendoc,"enter RTIambassador::updateAttributeValues without time");
     Message req, rep ;
 
     req.type = Message::UPDATE_ATTRIBUTE_VALUES ;
@@ -1224,6 +1226,7 @@
     req.setBoolean(false);
 
     privateRefs->executeService(&req, &rep);
+    G.Out(pdGendoc,"exit  RTIambassador::updateAttributeValues without time");
 }
 
 // ----------------------------------------------------------------------------
@@ -3012,4 +3015,4 @@
     privateRefs->executeService(&req, &rep);
 }
 
-// $Id: RTIambassador.cc,v 3.88 2008/06/12 07:39:51 erk Exp $
+// $Id: RTIambassador.cc,v 3.89 2008/06/24 08:56:49 rousse Exp $




reply via email to

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