Add methods in base SimObject to turn whole sim object on/off.

Added enable/disable methods to the SimObject base class.  Used
enable/disable to be consistent with the JobData class that already
had these defined.

fixes #103
This commit is contained in:
Alex Lin 2015-08-05 15:17:32 -05:00
parent e12ddbcfe1
commit 80fb82e9f6
2 changed files with 27 additions and 2 deletions

View File

@ -47,6 +47,9 @@ namespace Trick {
/** Jobs in this sim_object */
std::vector <Trick::JobData *> jobs ; /* trick_io(**) */
/** Default destructor that doesn't do anything. */
virtual ~SimObject() ;
/** Returns a job with a specific name. */
Trick::JobData * get_job( std::string job_name , unsigned int instance_num = 1 ) ;
@ -90,8 +93,16 @@ namespace Trick {
double in_cycle, const char * in_name, const char * in_tag = "", int in_phase = 60000 ,
double in_start = 0.0 , double in_stop = 1.0e37) ;
/** Default destructor that doesn't do anything. */
virtual ~SimObject() ;
/**
* Enables all jobs in the SimObject
*/
void enable() ;
/**
* Disables all jobs in the SimObject
*/
void disable() ;
/**
* Calls all jobs that are not "dynamic_event" class

View File

@ -99,3 +99,17 @@ Trick::JobData * Trick::SimObject::get_job( std::string job_name, unsigned int j
return NULL ;
}
void Trick::SimObject::enable() {
std::vector <Trick::JobData *>::iterator it ;
for ( it = jobs.begin() ; it != jobs.end() ; it++ ) {
(*it)->enable() ;
}
}
void Trick::SimObject::disable() {
std::vector <Trick::JobData *>::iterator it ;
for ( it = jobs.begin() ; it != jobs.end() ; it++ ) {
(*it)->disable() ;
}
}