1
0
Fork 0

Give TimeManager a subsystem-name

Also modernise the lookups now this is added.
This commit is contained in:
James Turner 2018-01-29 10:46:08 +00:00
parent 193d7b1c6f
commit 4d28146796
2 changed files with 14 additions and 16 deletions

View file

@ -99,7 +99,6 @@ using std::vector;
extern int _bootstrap_OSInit; extern int _bootstrap_OSInit;
static SGPropertyNode_ptr frame_signal; static SGPropertyNode_ptr frame_signal;
static TimeManager* timeMgr;
// What should we do when we have nothing else to do? Let's get ready // What should we do when we have nothing else to do? Let's get ready
// for the next move and update the display? // for the next move and update the display?
@ -113,10 +112,11 @@ static void fgMainLoop( void )
frame_signal->fireValueChanged(); frame_signal->fireValueChanged();
auto timeManager = globals->get_subsystem<TimeManager>();
// compute simulated time (allowing for pause, warp, etc) and // compute simulated time (allowing for pause, warp, etc) and
// real elapsed time // real elapsed time
double sim_dt, real_dt; double sim_dt, real_dt;
timeMgr->computeTimeDeltas(sim_dt, real_dt); timeManager->computeTimeDeltas(sim_dt, real_dt);
// update all subsystems // update all subsystems
globals->get_subsystem_mgr()->update(sim_dt); globals->get_subsystem_mgr()->update(sim_dt);
@ -236,7 +236,6 @@ static void registerMainLoop()
{ {
// stash current frame signal property // stash current frame signal property
frame_signal = fgGetNode("/sim/signals/frame", true); frame_signal = fgGetNode("/sim/signals/frame", true);
timeMgr = (TimeManager*) globals->get_subsystem("time");
fgRegisterIdleHandler( fgMainLoop ); fgRegisterIdleHandler( fgMainLoop );
} }
@ -279,8 +278,7 @@ static void fgIdleFunction ( void ) {
} else if ( idle_state == 4 ) { } else if ( idle_state == 4 ) {
idle_state++; idle_state++;
TimeManager* t = new TimeManager; globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT);
globals->add_subsystem("time", t, SGSubsystemMgr::INIT);
// Do some quick general initializations // Do some quick general initializations
if( !fgInitGeneral()) { if( !fgInitGeneral()) {
@ -308,7 +306,7 @@ static void fgIdleFunction ( void ) {
simgear::SGModelLib::init(globals->get_fg_root().local8BitStr(), globals->get_props()); simgear::SGModelLib::init(globals->get_fg_root().local8BitStr(), globals->get_props());
TimeManager* timeManager = (TimeManager*) globals->get_subsystem("time"); auto timeManager = globals->get_subsystem<TimeManager>();
timeManager->init(); timeManager->init();
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View file

@ -35,19 +35,19 @@ public:
void computeTimeDeltas(double& simDt, double& realDt); void computeTimeDeltas(double& simDt, double& realDt);
virtual void init(); void init() override;
virtual void reinit(); void reinit() override;
virtual void postinit(); void postinit() override;
virtual void shutdown(); void shutdown() override;
void unbind() override;
void update(double dt) override;
virtual void unbind(); // SGPropertyChangeListener overrides
void valueChanged(SGPropertyNode *) override;
void update(double dt);
// SGPropertyChangeListener overrides
virtual void valueChanged(SGPropertyNode *);
void setTimeOffset(const std::string& offset_type, long int offset); void setTimeOffset(const std::string& offset_type, long int offset);
static const char* subsystemName() { return "time"; }
private: private:
/** /**