Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2015, 10:24:56 AM (9 years ago)
Author:
landauf
Message:

moved macro ans helperfunction from NetworkFunction.h to NetworkFunctionIncludes.h

Location:
code/branches/core7/src/libraries/network
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/network/NetworkFunction.h

    r9667 r10465  
    3636#include <map>
    3737#include <string>
    38 #include <boost/preprocessor/cat.hpp>
    39 #include <boost/static_assert.hpp>
    4038
    4139#include "core/object/Listable.h"
     
    237235}
    238236
    239 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    240 {
    241   BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
    242   NetworkFunctionPointer destptr;
    243   copyPtr( ptr, destptr );
    244   new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
    245   return 0;
    246237}
    247238
    248 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    249 {
    250   BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
    251   NetworkFunctionPointer destptr;
    252   copyPtr( ptr, destptr );
    253   new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
    254   return 0;
    255 }
    256 
    257 #define registerStaticNetworkFunction( functionPointer ) \
    258   static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
    259 #define registerMemberNetworkFunction( class, function ) \
    260   static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
    261   // call it with functionPointer, clientID, args
    262 #define callStaticNetworkFunction( functionPointer, ...) \
    263   { \
    264     NetworkFunctionPointer p1; \
    265     copyPtr( functionPointer, p1 ); \
    266     FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
    267   }
    268   // call it with class, function, objectID, clientID, args
    269 #define callMemberNetworkFunction( class, function, objectID, ...) \
    270   { \
    271     NetworkFunctionPointer p1; \
    272     copyPtr( &class::function, p1 ); \
    273     FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
    274   }
    275 
    276 
    277 }
    278 
    279239#endif /* _NetworkFunction_H__ */
Note: See TracChangeset for help on using the changeset viewer.