[Orxonox-commit 323] r2949 - in branches/netp2/src: network network/packet orxonox/objects orxonox/objects/worldentities/pawns util

scheusso at orxonox.net scheusso at orxonox.net
Sat May 2 16:19:44 CEST 2009


Author: scheusso
Date: 2009-05-02 16:19:43 +0200 (Sat, 02 May 2009)
New Revision: 2949

Modified:
   branches/netp2/src/network/FunctionCallManager.cc
   branches/netp2/src/network/FunctionCallManager.h
   branches/netp2/src/network/Server.cc
   branches/netp2/src/network/packet/FunctionCalls.cc
   branches/netp2/src/network/packet/FunctionCalls.h
   branches/netp2/src/orxonox/objects/Test.cc
   branches/netp2/src/orxonox/objects/Test.h
   branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.cc
   branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.h
   branches/netp2/src/util/MultiType.h
Log:
Network Function calls possible now (already used in Pawn::fire/doFire)

include "network/NetworkFunction.h"
register network functions like this:
	registerStaticNetworkFunction( functionPointer );     // this is for static (member) functions
	registerMemberNetworkFunction( class, function );     // this is for non-static member functions
call network functions like this:
	callStaticNetworkFunction( functionPointer, clientID, arg1, ... );		// clientID is 0 for server
	callMemberNetworkFunction( class, function, objectID, clientID, arg1, ... );	// objectID can be obtained by this->getObjectID() for synchronisables
arguments must be supported by MultiType !!
object must inherit from Synchronisable !!


Modified: branches/netp2/src/network/FunctionCallManager.cc
===================================================================
--- branches/netp2/src/network/FunctionCallManager.cc	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/network/FunctionCallManager.cc	2009-05-02 14:19:43 UTC (rev 2949)
@@ -33,26 +33,123 @@
     
 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
 
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5)
+// Static calls
+
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
 {  
   if(clientMap_.find(clientID)==clientMap_.end()) 
   {
     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
     FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
   } 
-  FunctionCallManager::	clientMap_[clientID]->addCallStatic(functionID, mt1, mt2, mt3, mt4, mt5);
+  FunctionCallManager::	clientMap_[clientID]->addCallStatic(functionID);
 }
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
+}
 
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5)
+
+// MemberCalls
+
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
 { 
   if(clientMap_.find(clientID)==clientMap_.end()) 
   {
     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
     FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
   } 
-  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
 }
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
+}
 
+// Send calls
+
 void FunctionCallManager::sendCalls()
 {
   std::map<uint32_t, packet::FunctionCalls*>::iterator it;

Modified: branches/netp2/src/network/FunctionCallManager.h
===================================================================
--- branches/netp2/src/network/FunctionCallManager.h	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/network/FunctionCallManager.h	2009-05-02 14:19:43 UTC (rev 2949)
@@ -17,8 +17,20 @@
 class _NetworkExport FunctionCallManager
 {
 public:
-  static void addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  
   static void sendCalls();
   
   static std::map<uint32_t, packet::FunctionCalls*> clientMap_;

Modified: branches/netp2/src/network/Server.cc
===================================================================
--- branches/netp2/src/network/Server.cc	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/network/Server.cc	2009-05-02 14:19:43 UTC (rev 2949)
@@ -350,6 +350,7 @@
     
     // now synchronise functionIDs
     packet::FunctionIDs *fIDs = new packet::FunctionIDs();
+    fIDs->setClientID(clientID);
     bool b = fIDs->send();
     assert(b);
     

Modified: branches/netp2/src/network/packet/FunctionCalls.cc
===================================================================
--- branches/netp2/src/network/packet/FunctionCalls.cc	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/network/packet/FunctionCalls.cc	2009-05-02 14:19:43 UTC (rev 2949)
@@ -170,7 +170,7 @@
   return true;
 }
 
-void FunctionCalls::addCallStatic( uint32_t networkID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5){
+void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
   
   // first determine the size that has to be reserved for this call
@@ -244,7 +244,7 @@
   
 }
 
-void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5){
+void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
   
   // first determine the size that has to be reserved for this call

Modified: branches/netp2/src/network/packet/FunctionCalls.h
===================================================================
--- branches/netp2/src/network/packet/FunctionCalls.h	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/network/packet/FunctionCalls.h	2009-05-02 14:19:43 UTC (rev 2949)
@@ -31,8 +31,8 @@
     { assert(!this->isDataENetAllocated()); return currentSize_; }
   bool process();
 
-  void addCallStatic( uint32_t networkID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
-  void addCallMember( uint32_t networkID, uint32_t objectID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
+  void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
 private:
   uint32_t nrOfCalls_;
   unsigned int clientID_;

Modified: branches/netp2/src/orxonox/objects/Test.cc
===================================================================
--- branches/netp2/src/orxonox/objects/Test.cc	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/orxonox/objects/Test.cc	2009-05-02 14:19:43 UTC (rev 2949)
@@ -32,6 +32,7 @@
 #include "core/ConsoleCommand.h"
 #include "network/NetworkFunction.h"
 #include "Test.h"
+#include "util/MultiType.h"
 
 namespace orxonox
 {
@@ -42,6 +43,7 @@
   SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
   SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
   SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
+  SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
   
   
   //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
@@ -50,6 +52,7 @@
   
   registerStaticNetworkFunction( &Test::printV1 );
   registerMemberNetworkFunction( Test, checkU1 );
+  registerMemberNetworkFunction( Test, printBlaBla );
   
   Test* Test::instance_ = 0;
 
@@ -101,13 +104,35 @@
     callStaticNetworkFunction( &Test::printV1, clientID );
   }
   
+  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
+  {
+    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+  }
+  
   void Test::tick(float dt)
   {
+//     std::string str1 = "blub";
+//     //MultiType mt1(std::string("blub"));
+//     MultiType mt1(str1);
+//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
+//     uint8_t* temp = mem;
+//     mt1.exportData( temp );
+//     assert( temp-mem == mt1.getNetworkSize() );
+//     MultiType mt2;
+//     temp = mem;
+//     mt2.importData( temp );
+//     assert( temp-mem == mt1.getNetworkSize() );
+//     COUT(0) << mt2 << endl;
     if(!Core::isMaster())
-      callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
-//       callMemberNetworkFunction( &Test::printV1, this->getObjectID(), 0);
+      call2(0, "bal", "a", "n", "ce");
+//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
   }
   
+  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
+  {
+    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+  }
+  
   void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
   void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
   void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }

Modified: branches/netp2/src/orxonox/objects/Test.h
===================================================================
--- branches/netp2/src/orxonox/objects/Test.h	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/orxonox/objects/Test.h	2009-05-02 14:19:43 UTC (rev 2949)
@@ -51,6 +51,7 @@
       void registerVariables();
       
       static void call(unsigned int clientID);
+      void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
       virtual void tick(float dt);
 
 
@@ -78,6 +79,8 @@
       static void printV2(){ instance_->checkU2(); }
       static void printV3(){ instance_->checkU3(); }
       static void printV4(){ instance_->checkU4(); }
+      
+      void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
 
     private:
       UTYPE u1;

Modified: branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-02 14:19:43 UTC (rev 2949)
@@ -38,10 +38,13 @@
 #include "objects/gametypes/Gametype.h"
 #include "objects/worldentities/ParticleSpawner.h"
 #include "objects/worldentities/ExplosionChunk.h"
+#include "network/NetworkFunction.h"
 
 namespace orxonox
 {
     CreateFactory(Pawn);
+    
+    registerMemberNetworkFunction( Pawn, doFire );
 
     Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
     {
@@ -116,17 +119,17 @@
     {
         SUPER(Pawn, tick, dt);
 
-        if (this->weaponSystem_)
-        {
-            if (this->fire_ & WeaponMode::fire)
-                this->weaponSystem_->fire(WeaponMode::fire);
-            if (this->fire_ & WeaponMode::altFire)
-                this->weaponSystem_->fire(WeaponMode::altFire);
-            if (this->fire_ & WeaponMode::altFire2)
-                this->weaponSystem_->fire(WeaponMode::altFire2);
-        }
-        this->fire_ = this->firehack_;
-        this->firehack_ = 0x0;
+//         if (this->weaponSystem_)
+//         {
+//             if (this->fire_ & WeaponMode::fire)
+//                 this->weaponSystem_->fire(WeaponMode::fire);
+//             if (this->fire_ & WeaponMode::altFire)
+//                 this->weaponSystem_->fire(WeaponMode::altFire);
+//             if (this->fire_ & WeaponMode::altFire2)
+//                 this->weaponSystem_->fire(WeaponMode::altFire2);
+//         }
+//         this->fire_ = this->firehack_;
+//         this->firehack_ = 0x0;
 
         if (Core::isMaster())
           if (this->health_ <= 0)
@@ -255,8 +258,23 @@
 
     void Pawn::fire(WeaponMode::Enum fireMode)
     {
-        this->firehack_ |= fireMode;
+        doFire(fireMode);
     }
+    
+    void Pawn::doFire(uint8_t fireMode)
+    {
+        if(Core::isMaster())
+        {
+            if (this->weaponSystem_)
+                this->weaponSystem_->fire((WeaponMode::Enum)fireMode);
+        }
+        else
+        {
+            callMemberNetworkFunction( Pawn, doFire, this->getObjectID(), 0, ((uint8_t)fireMode));
+            if (this->weaponSystem_)
+                this->weaponSystem_->fire((WeaponMode::Enum)fireMode);
+        }
+    }
 
     void Pawn::postSpawn()
     {

Modified: branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-02 14:19:43 UTC (rev 2949)
@@ -79,6 +79,7 @@
             virtual void kill();
 
             virtual void fire(WeaponMode::Enum fireMode);
+            virtual void doFire(uint8_t fireMode);
             virtual void postSpawn();
 
             void setWeaponSlot(WeaponSlot * wSlot);

Modified: branches/netp2/src/util/MultiType.h
===================================================================
--- branches/netp2/src/util/MultiType.h	2009-05-01 21:34:14 UTC (rev 2948)
+++ branches/netp2/src/util/MultiType.h	2009-05-02 14:19:43 UTC (rev 2949)
@@ -79,30 +79,30 @@
     */
     enum MT_Type
     {
-        MT_null,
-        MT_char,
-        MT_uchar,
-        MT_short,
-        MT_ushort,
-        MT_int,
-        MT_uint,
-        MT_long,
-        MT_ulong,
-        MT_longlong,
-        MT_ulonglong,
-        MT_float,
-        MT_double,
-        MT_longdouble,
-        MT_bool,
-        MT_void,
-        MT_string,
-        MT_vector2,
-        MT_vector3,
-        MT_vector4,
-        MT_colourvalue,
-        MT_quaternion,
-        MT_radian,
-        MT_degree
+        MT_null=0,
+        MT_char=1,
+        MT_uchar=2,
+        MT_short=3,
+        MT_ushort=4,
+        MT_int=5,
+        MT_uint=6,
+        MT_long=7,
+        MT_ulong=8,
+        MT_longlong=9,
+        MT_ulonglong=10,
+        MT_float=11,
+        MT_double=12,
+        MT_longdouble=13,
+        MT_bool=14,
+        MT_void=15,
+        MT_string=16,
+        MT_vector2=17,
+        MT_vector3=18,
+        MT_vector4=19,
+        MT_colourvalue=20,
+        MT_quaternion=21,
+        MT_radian=22,
+        MT_degree=23
     };
 
     /**
@@ -325,14 +325,14 @@
             std::string                       getTypename()             const;
             
             /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
-            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->importData(mem); }
+            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
             /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
-            inline void                       exportData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(*(uint8_t*)mem); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
+            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
             /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
             inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
             /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
-            inline void                       operator >> (uint8_t*& mem) { exportData(mem); }
-            inline uint32_t                   getNetworkSize() { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
+            inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
+            inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
 
             /** @brief Checks whether the value is a default one. */
             bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }




More information about the Orxonox-commit mailing list