Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2015, 1:51:40 PM (9 years ago)
Author:
landauf
Message:

use the same interface for static an member functions

File:
1 edited

Legend:

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

    r10471 r10472  
    7676    inline const std::string& getName() const           { return name_; }
    7777
    78   private:
    79     uint32_t networkID_;
    80     std::string name_;
    81 
    82 };
    83 
    84 
    85 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    86   public:
    87     NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
    88         : NetworkFunctionBase(name, p)
    89         , functor_(functor)
    90     { }
    91 
    92     inline void call(){ (*this->functor_)(); }
    93     inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
    94     inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
    95     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
    96     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
    97     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); }
    98 
    99   private:
    100     FunctorStaticPtr functor_;
    101 
    102 };
    103 
    104 
    105 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
    106   public:
    107     NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
    108         : NetworkFunctionBase(name, p)
    109     { }
    110 
    111     //
    11278    virtual bool call(uint32_t objectID)=0;
    11379    virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
     
    11682    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
    11783    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
     84
     85  private:
     86    uint32_t networkID_;
     87    std::string name_;
     88
     89};
     90
     91
     92class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
     93  public:
     94    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
     95        : NetworkFunctionBase(name, p)
     96        , functor_(functor)
     97    { }
     98
     99    // ignore the objectID because its a static function
     100    virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
     101    virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
     102    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
     103    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
     104    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
     105    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
     106
     107  private:
     108    FunctorStaticPtr functor_;
     109
     110};
     111
     112
     113class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
     114  public:
     115    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
     116        : NetworkFunctionBase(name, p)
     117    { }
    118118};
    119119
Note: See TracChangeset for help on using the changeset viewer.