Changeset 3214 for code/trunk/src/network/NetworkFunction.h
- Timestamp:
- Jun 23, 2009, 6:02:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/NetworkFunction.h
r3196 r3214 27 27 */ 28 28 29 #ifndef NETWORKFUNCTION_H30 #define NETWORKFUNCTION_H29 #ifndef _NetworkFunction_H__ 30 #define _NetworkFunction_H__ 31 31 32 32 #include "NetworkPrereqs.h" 33 34 #include <cassert> 35 #include <cstring> 36 #include <map> 37 #include <string> 38 #include <boost/preprocessor/cat.hpp> 39 33 40 #include "core/OrxonoxClass.h" 34 35 #include <string>36 #include <map>37 #include <cassert>38 #include <boost/preprocessor/cat.hpp>39 #include "util/MultiType.h"40 41 #include "core/Functor.h" 42 #include "FunctionCallManager.h" 41 43 #include "synchronisable/Synchronisable.h" 42 #include "OrxonoxConfig.h"43 #include "FunctionCallManager.h"44 45 44 46 45 namespace orxonox … … 72 71 class _NetworkExport NetworkFunctionBase: virtual public OrxonoxClass { 73 72 public: 74 NetworkFunctionBase( std::stringname);73 NetworkFunctionBase(const std::string& name); 75 74 ~NetworkFunctionBase(); 76 75 77 inline voidsetNetworkID(uint32_t id) { this->networkID_ = id; }76 virtual void setNetworkID(uint32_t id) { this->networkID_ = id; } 78 77 inline uint32_t getNetworkID() const { return this->networkID_; } 79 inline std::string getName() const{ return name_; }78 inline const std::string& getName() const { return name_; } 80 79 static inline bool isStatic( uint32_t networkID ) { return isStaticMap_[networkID]; } 81 80 82 static inline void setNetworkID( std::stringname, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }81 static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); } 83 82 84 83 protected: … … 95 94 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 96 95 public: 97 NetworkFunctionStatic(FunctorStatic* functor, std::stringname, const NetworkFunctionPointer& p);96 NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p); 98 97 ~NetworkFunctionStatic(); 99 98 … … 105 104 inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); } 106 105 106 virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; } 107 107 static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; } 108 108 static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; } … … 120 120 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase { 121 121 public: 122 NetworkMemberFunctionBase( std::stringname, const NetworkFunctionPointer& p);122 NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p); 123 123 ~NetworkMemberFunctionBase(); 124 124 125 virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; } 125 126 static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; } 126 127 static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; } … … 143 144 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase { 144 145 public: 145 NetworkMemberFunction(FunctorMember<T>* functor, std::stringname, const NetworkFunctionPointer& p);146 NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p); 146 147 ~NetworkMemberFunction(); 147 148 … … 181 182 }; 182 183 183 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::stringname, const NetworkFunctionPointer& p):184 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p): 184 185 NetworkMemberFunctionBase(name, p), functor_(functor) 185 186 { … … 199 200 } 200 201 201 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, std::stringname )202 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name ) 202 203 { 203 204 NetworkFunctionPointer destptr; … … 207 208 } 208 209 209 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, std::stringname )210 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name ) 210 211 { 211 212 NetworkFunctionPointer destptr; … … 237 238 } 238 239 239 #endif 240 #endif /* _NetworkFunction_H__ */
Note: See TracChangeset
for help on using the changeset viewer.