[Orxonox-commit 2474] r7181 - code/branches/consolecommands3/src/libraries/network/synchronisable
landauf at orxonox.net
landauf at orxonox.net
Wed Aug 18 16:01:39 CEST 2010
Author: landauf
Date: 2010-08-18 16:01:38 +0200 (Wed, 18 Aug 2010)
New Revision: 7181
Modified:
code/branches/consolecommands3/src/libraries/network/synchronisable/Serialise.h
Log:
Great, looks like I created some circular dependencies between BaseObject, SmartPtr, and Functor. Lets fix this later, just a quick workaround for now.
Modified: code/branches/consolecommands3/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/branches/consolecommands3/src/libraries/network/synchronisable/Serialise.h 2010-08-18 13:43:11 UTC (rev 7180)
+++ code/branches/consolecommands3/src/libraries/network/synchronisable/Serialise.h 2010-08-18 14:01:38 UTC (rev 7181)
@@ -38,25 +38,26 @@
#include "util/TypeTraits.h"
#include "core/CorePrereqs.h"
#include "core/CoreIncludes.h"
-#include "core/SmartPtr.h"
+#include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed
+//#include "core/SmartPtr.h"
namespace orxonox{
-
+
// These functions implement loading / saving / etc. for pointer types
-
+
/** @brief returns the size of the objectID needed to synchronise the pointer */
template <class T> inline uint32_t returnSize( T*& variable )
{
return sizeof(uint32_t);
}
-
+
/** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem )
{
*const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
mem += returnSize( variable );
}
-
+
/** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem )
{
@@ -66,7 +67,7 @@
*(uint32_t*)(mem) = OBJECTID_UNKNOWN;
mem += returnSize( variable );
}
-
+
/** @brief checks whether the objectID of the variable is the same as in the bytestream */
template <class T> inline bool checkEquality( T*& variable, uint8_t* mem )
{
@@ -75,15 +76,15 @@
else
return variable == variable->getSynchronisable(*(uint32_t*)(mem));
}
-
+
// These functions implement loading / saving / etc. for SmartPtr<T>
-
+
/** @brief returns the size of the objectID needed to synchronise the pointer */
template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
{
return sizeof(uint32_t);
}
-
+
/** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
{
@@ -91,7 +92,7 @@
*const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
mem += returnSize( variable );
}
-
+
/** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
{
@@ -101,7 +102,7 @@
*(uint32_t*)(mem) = OBJECTID_UNKNOWN;
mem += returnSize( variable );
}
-
+
/** @brief checks whether the objectID of the variable is the same as in the bytestream */
template <class T> inline bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
{
@@ -110,15 +111,15 @@
else
return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
}
-
+
// These functions implement loading / saving / etc. for WeakPtr<T>
-
+
/** @brief returns the size of the objectID needed to synchronise the pointer */
template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable )
{
return sizeof(uint32_t);
}
-
+
/** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
{
@@ -126,7 +127,7 @@
*const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
mem += returnSize( variable );
}
-
+
/** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
{
@@ -136,7 +137,7 @@
*(uint32_t*)(mem) = OBJECTID_UNKNOWN;
mem += returnSize( variable );
}
-
+
/** @brief checks whether the objectID of the variable is the same as in the bytestream */
template <class T> inline bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem )
{
More information about the Orxonox-commit
mailing list