Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2009, 9:35:10 PM (15 years ago)
Author:
scheusso
Message:

merged netp2 → netp3

Location:
code/branches/netp3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3

  • code/branches/netp3/src/orxonox/objects/Test.cc

    r2662 r2990  
    3131#include "core/ConfigValueIncludes.h"
    3232#include "core/ConsoleCommand.h"
     33#include "network/NetworkFunction.h"
    3334#include "Test.h"
     35#include "util/MultiType.h"
    3436
    3537namespace orxonox
     
    4143  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
    4244  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
     45  SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
     46  SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
     47 
     48 
     49  //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
     50  //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
     51//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
     52 
     53  registerStaticNetworkFunction( &Test::printV1 );
     54  registerMemberNetworkFunction( Test, checkU1 );
     55  registerMemberNetworkFunction( Test, printBlaBla );
    4356 
    4457  Test* Test::instance_ = 0;
     
    7386
    7487
    75         void Test::registerVariables()
    76         {
    77                 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     88  void Test::registerVariables()
     89  {
     90    registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
    7891    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
    79                 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     92    registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
    8093    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
    8194   
     
    8497    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
    8598    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    86         }
    87 
     99  }
     100 
     101  void Test::call(unsigned int clientID)
     102  {
     103    callStaticNetworkFunction( &Test::printV1, clientID );
     104    callStaticNetworkFunction( &Test::printV1, clientID );
     105  }
     106 
     107  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     108  {
     109    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     110  }
     111 
     112  void Test::tick(float dt)
     113  {
     114//     std::string str1 = "blub";
     115//     //MultiType mt1(std::string("blub"));
     116//     MultiType mt1(str1);
     117//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
     118//     uint8_t* temp = mem;
     119//     mt1.exportData( temp );
     120//     assert( temp-mem == mt1.getNetworkSize() );
     121//     MultiType mt2;
     122//     temp = mem;
     123//     mt2.importData( temp );
     124//     assert( temp-mem == mt1.getNetworkSize() );
     125//     COUT(0) << mt2 << endl;
     126    if(!Core::isMaster())
     127      call2(0, "bal", "a", "n", "ce");
     128//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
     129  }
     130 
     131  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
     132  {
     133    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
     134  }
     135 
    88136  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
    89137  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
Note: See TracChangeset for help on using the changeset viewer.