Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 22, 2010, 3:49:23 PM (15 years ago)
Author:
scheusso
Message:

unregisterVariable reintroduced
some style changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network2/src/libraries/network/synchronisable/Synchronisable.h

    r6450 r6455  
    177177    Synchronisable(BaseObject* creator);
    178178    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
     179    template <class T> void unregisterVariable(T& var);
    179180
    180181    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
     
    219220    }
    220221  }
     222 
     223  template <class T> void Synchronisable::unregisterVariable(T& variable){
     224    std::vector<SynchronisableVariableBase*>::iterator it = syncList_.begin();
     225    while(it!=syncList_.end()){
     226      if( ((*it)->getReference()) == &variable ){
     227        delete (*it);
     228        syncList_.erase(it);
     229        return;
     230      }
     231      else
     232        it++;
     233    }
     234    bool unregistered_nonexistent_variable = false;
     235    assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
     236    // the variable has not been registered before
     237  }
    221238
    222239  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
     240  template <> _NetworkExport void Synchronisable::unregisterVariable( std::string& variable );
    223241
    224242
Note: See TracChangeset for help on using the changeset viewer.