Changeset 10465 for code/branches/core7/src/libraries/network
- Timestamp:
- May 25, 2015, 10:24:56 AM (10 years ago)
- 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 36 36 #include <map> 37 37 #include <string> 38 #include <boost/preprocessor/cat.hpp>39 #include <boost/static_assert.hpp>40 38 41 39 #include "core/object/Listable.h" … … 237 235 } 238 236 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 above242 NetworkFunctionPointer destptr;243 copyPtr( ptr, destptr );244 new NetworkFunctionStatic( createFunctor(ptr), name, destptr );245 return 0;246 237 } 247 238 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 above251 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, args262 #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, args269 #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 279 239 #endif /* _NetworkFunction_H__ */
Note: See TracChangeset
for help on using the changeset viewer.