Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 6:02:25 PM (15 years ago)
Author:
scheusso
Message:

merged netp5 back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/NetworkFunction.h

    r3196 r3214  
    2727 */
    2828
    29 #ifndef NETWORKFUNCTION_H
    30 #define NETWORKFUNCTION_H
     29#ifndef _NetworkFunction_H__
     30#define _NetworkFunction_H__
    3131
    3232#include "NetworkPrereqs.h"
     33
     34#include <cassert>
     35#include <cstring>
     36#include <map>
     37#include <string>
     38#include <boost/preprocessor/cat.hpp>
     39
    3340#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"
    4041#include "core/Functor.h"
     42#include "FunctionCallManager.h"
    4143#include "synchronisable/Synchronisable.h"
    42 #include "OrxonoxConfig.h"
    43 #include "FunctionCallManager.h"
    44 
    4544
    4645namespace orxonox
     
    7271class _NetworkExport NetworkFunctionBase: virtual public OrxonoxClass {
    7372  public:
    74     NetworkFunctionBase(std::string name);
     73    NetworkFunctionBase(const std::string& name);
    7574    ~NetworkFunctionBase();
    7675   
    77     inline void         setNetworkID(uint32_t id)       { this->networkID_ = id; }
     76    virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
    7877    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_; }
    8079    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
    8180   
    82     static inline void setNetworkID(std::string name, 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); }
    8382   
    8483  protected:
     
    9594class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    9695  public:
    97     NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p);
     96    NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
    9897    ~NetworkFunctionStatic();
    9998   
     
    105104    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); }
    106105   
     106    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
    107107    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
    108108    static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
     
    120120class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
    121121  public:
    122     NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p);
     122    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
    123123    ~NetworkMemberFunctionBase();
    124124   
     125    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
    125126    static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
    126127    static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
     
    143144template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
    144145  public:
    145     NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p);
     146    NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
    146147    ~NetworkMemberFunction();
    147148   
     
    181182};
    182183
    183 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p):
     184template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p):
    184185    NetworkMemberFunctionBase(name, p), functor_(functor)
    185186{
     
    199200}
    200201
    201 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, std::string name )
     202template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    202203{
    203204  NetworkFunctionPointer destptr;
     
    207208}
    208209
    209 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, std::string name )
     210template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    210211{
    211212  NetworkFunctionPointer destptr;
     
    237238}
    238239
    239 #endif
     240#endif /* _NetworkFunction_H__ */
Note: See TracChangeset for help on using the changeset viewer.