Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2143 for code/branches


Ignore:
Timestamp:
Nov 5, 2008, 3:43:16 PM (16 years ago)
Author:
scheusso
Message:

added a function unregisterVariable to unregister variable that has been registered inside a synchronisable before
use it like this:
unregisterVariable(&this→myVar_) if you registered the variable with REGISTERDATA(this→myVar_)

Location:
code/branches/objecthierarchy/src/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r2133 r2143  
    251251  * @param cb callback object that should get called, if the value of the variable changes
    252252  */
    253   void Synchronisable::registerVar(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
     253  void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
    254254    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
    255255    // create temporary synch.Var struct
     
    285285#endif
    286286  }
     287 
     288  void Synchronisable::unregisterVariable(void *var){
     289    std::list<synchronisableVariable *>::iterator it = syncList->begin();
     290    while(it!=syncList->end()){
     291      if( (*it)->var == var ){
     292        delete *it;
     293        syncList->erase(it);
     294        return;
     295      }
     296      else
     297        it++;
     298    }
     299    assert(0); //if we reach this point something went wrong
     300  }
     301 
    287302
    288303  /**
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r2132 r2143  
    4242
    4343#define REGISTERDATA(varname, ...) \
    44     registerVar((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
     44    registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
    4545#define REGISTERSTRING(stringname, ...) \
    46     registerVar(&stringname, stringname.length()+1, STRING, __VA_ARGS__)
     46    registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)
    4747
    4848namespace orxonox
     
    115115  protected:
    116116    Synchronisable(BaseObject* creator);
    117     void registerVar(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
     117    void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
     118    void unregisterVariable(void *var);
    118119    void setObjectMode(uint8_t mode);
    119120    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
Note: See TracChangeset for help on using the changeset viewer.