Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 1, 2009, 11:34:14 PM (16 years ago)
Author:
scheusso
Message:

member function calls should work now
argument transfer still untested

Location:
code/branches/netp2/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp2/src/network/Client.cc

    r2773 r2948  
    4747#include "core/CoreIncludes.h"
    4848#include "packet/Packet.h"
     49#include "FunctionCallManager.h"
    4950
    5051// #include "packet/Acknowledgement.h"
     
    149150        // gs gets automatically deleted by enet callback
    150151      }
     152      FunctionCallManager::sendCalls();
    151153    }
    152154    ENetEvent *event;
  • code/branches/netp2/src/network/NetworkFunction.cc

    r2944 r2948  
    7070  NetworkFunctionStatic::~NetworkFunctionStatic()
    7171  {
     72    delete this->functor_;
    7273  }
    7374 
  • code/branches/netp2/src/network/NetworkFunction.h

    r2944 r2948  
    3838#include "util/MultiType.h"
    3939#include "synchronisable/Synchronisable.h"
     40#include "OrxonoxConfig.h"
    4041#include "FunctionCallManager.h"
    4142
     
    158159{
    159160}
    160 
     161template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
     162{
     163  delete this->functor_;
     164}
    161165
    162166template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
     
    173177  NetworkFunctionPointer destptr;
    174178  copyPtr( ptr, destptr );
    175   COUT(0) << "-==================== destptr: " << destptr.pointer[0] << ", " << destptr.pointer[1] << endl;
    176179  new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
    177180  return 0;
     
    182185  NetworkFunctionPointer destptr;
    183186  copyPtr( ptr, destptr );
    184   new NetworkMemberFunction<T>( new FunctorMember<T>(ptr), name, destptr );
     187  new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
    185188  return 0;
    186189}
    187190
    188 #define registerStaticNetworkFunction( functionPointer, name ) \
    189   void* NETWORK_FUNCTION_name##a = registerStaticNetworkFunctionFct( functionPointer, name );
    190 #define registerMemberNetworkFunction( functionPointer, class, name ) \
    191   void* NETWORK_FUNCTION_class##name##a = registerMemberNetworkFunction<class>( functionPointer, name );
     191#define registerStaticNetworkFunction( functionPointer ) \
     192  static void* MACRO_CONCATENATE( NETWORK_FUNCTION_, __LINE__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
     193#define registerMemberNetworkFunction( class, function ) \
     194  static void* MACRO_CONCATENATE( NETWORK_FUNCTION_##class, __LINE__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
     195  // call it with functionPointer, clientID, args
    192196#define callStaticNetworkFunction( functionPointer, ...) \
    193197  { \
     
    196200    FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
    197201  }
    198 #define callMemberNetworkFunction( functionPointer, objectID, ...) \
     202  // call it with class, function, objectID, clientID, args
     203#define callMemberNetworkFunction( class, function, objectID, ...) \
    199204  { \
    200205    NetworkFunctionPointer p1; \
    201     copyPtr( functionPointer, p1 ); \
    202     FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__) \
     206    copyPtr( &class::function, p1 ); \
     207    FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
    203208  }
    204209
  • code/branches/netp2/src/orxonox/objects/Test.cc

    r2944 r2948  
    4949//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
    5050 
    51   registerStaticNetworkFunction( &Test::printV1, "printV1" );
     51  registerStaticNetworkFunction( &Test::printV1 );
     52  registerMemberNetworkFunction( Test, checkU1 );
    5253 
    5354  Test* Test::instance_ = 0;
     
    101102  }
    102103 
     104  void Test::tick(float dt)
     105  {
     106    if(!Core::isMaster())
     107      callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
     108//       callMemberNetworkFunction( &Test::printV1, this->getObjectID(), 0);
     109  }
     110 
    103111  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
    104112  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
  • code/branches/netp2/src/orxonox/objects/Test.h

    r2944 r2948  
    3333#include "core/BaseObject.h"
    3434#include "network/synchronisable/Synchronisable.h"
     35#include "Tickable.h"
    3536
    3637
     
    4142namespace orxonox
    4243{
    43   class _OrxonoxExport Test: public BaseObject, public Synchronisable
     44  class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
    4445  {
    4546    public:
     
    5152     
    5253      static void call(unsigned int clientID);
     54      virtual void tick(float dt);
    5355
    5456
Note: See TracChangeset for help on using the changeset viewer.