Index: libstage/model.cc =================================================================== --- libstage/model.cc (revision 1980) +++ libstage/model.cc (working copy) @@ -640,7 +640,7 @@ world->total_subs++; world->dirty = true; // need redraw - //printf( "subscribe to %s %d\n", token, subs ); + //printf( "subscribe to %s %d\n", Token(), subs ); // if this is the first sub, call startup if( subs == 1 ) @@ -653,7 +653,7 @@ world->total_subs--; world->dirty = true; // need redraw - //printf( "unsubscribe from %s %d\n", token, subs ); + //printf( "unsubscribe from %s %d\n", Token(), subs ); // if this is the last sub, call shutdown if( subs == 0 ) Index: libstageplugin/p_driver.cc =================================================================== --- libstageplugin/p_driver.cc (revision 1980) +++ libstageplugin/p_driver.cc (working copy) @@ -228,7 +228,7 @@ ConfigFile* cf, int section, const std::string& type ) - : Interface( addr, driver, cf, section ) + : Interface( addr, driver, cf, section ), mod( NULL ), subscribed( false ) { char* model_name = (char*)cf->ReadString(section, "model", NULL ); @@ -260,7 +260,25 @@ printf( "\"%s\"\n", this->mod->Token() ); } +void InterfaceModel::Subscribe() +{ + if( !subscribed && this->mod ) + { + this->mod->Subscribe(); + subscribed = true; + } +} +void InterfaceModel::Unsubscribe() +{ + if( subscribed ) + { + this->mod->Unsubscribe(); + subscribed = false; + } +} + + // Constructor. Retrieve options from the configuration file and do any // pre-Setup() setup. Index: libstageplugin/p_driver.h =================================================================== --- libstageplugin/p_driver.h (revision 1980) +++ libstageplugin/p_driver.h (working copy) @@ -104,12 +104,16 @@ int section, const std::string& type ); + virtual ~InterfaceModel( void ){ Unsubscribe(); }; + + virtual void Subscribe( void ); + virtual void Unsubscribe( void ); + + protected: Stg::Model* mod; - virtual ~InterfaceModel( void ){ /* TODO: clean up*/ }; - - virtual void Subscribe( void ){ this->mod->Subscribe(); }; - virtual void Unsubscribe( void ){ this->mod->Unsubscribe(); }; + private: + bool subscribed; };