Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2008, 5:12:31 PM (16 years ago)
Author:
scheusso
Message:

bidirectional synchronisation works now:
register variables with mode direction::serverMaster or direction::clientMaster
clientMaster: both sides may change the variable but the client is master
serverMaster: both sides may change the variable but the server is master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/Test.cc

    r2112 r2132  
    3030#include "core/CoreIncludes.h"
    3131#include "core/ConfigValueIncludes.h"
     32#include "core/ConsoleCommand.h"
    3233#include "Test.h"
    3334
     
    3536{
    3637        CreateFactory ( Test );
     38 
     39  SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
     40  SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
     41  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
     42  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
     43 
     44  Test* Test::instance_ = 0;
    3745
    3846        Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    3947        {
     48    assert(instance_==0);
     49    instance_=this;
    4050                RegisterObject ( Test );
    41                 setConfigValues();
    42                 registerVariables();
     51    setConfigValues();
     52    registerVariables();
    4353                setObjectMode(0x3);
    4454        }
     
    4656        Test::~Test()
    4757        {
    48 
     58    instance_=0;
    4959        }
    5060
    5161        void Test::setConfigValues()
    5262        {
    53                 SetConfigValue ( v1, 1 ).callback ( this, &Test::checkV1 );
    54                 SetConfigValue ( v2, 2 ).callback ( this, &Test::checkV2 );
    55                 SetConfigValue ( v3, 3 ).callback ( this, &Test::checkV3 );
     63                SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     64    SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     65    SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     66    SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/;
    5667        }
    5768
     
    6071        {
    6172                REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
    62                 REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
    63                 REGISTERDATA ( v3,direction::bidirectional, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
     73    REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
     74                REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
     75    REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) );
    6476        }
    6577
    66         void Test::checkV1(){
    67                 COUT(1) << "V1 changed: " << v1 << std::endl;
    68         }
     78  void Test::checkV1(){
     79    COUT(1) << "V1 changed: " << v1 << std::endl;
     80  }
    6981
    70         void Test::checkV2(){
    71                 COUT(1) << "V2 changed: " << v2 << std::endl;
    72         }
     82  void Test::checkV2(){
     83    COUT(1) << "V2 changed: " << v2 << std::endl;
     84  }
    7385
    74         void Test::checkV3(){
    75                 COUT(1) << "V3 changed: " << v3 << std::endl;
    76         }
     86  void Test::checkV3(){
     87    COUT(1) << "V3 changed: " << v3 << std::endl;
     88  }
     89 
     90  void Test::checkV4(){
     91    COUT(1) << "V4 changed: " << v4 << std::endl;
     92  }
    7793
    7894
Note: See TracChangeset for help on using the changeset viewer.