From 10662e4ca5ee924932c355aca89bbc01f0b10817 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Tue, 3 Apr 2018 11:45:18 +0200 Subject: [PATCH] SGSubsystem classes: Subsystem and subsystem group API declaration standardisation. This is a cleanup commit. --- simgear/misc/interpolator.hxx | 5 ++- simgear/props/PropertyBasedMgr.hxx | 2 +- simgear/props/PropertyInterpolationMgr.hxx | 6 +-- simgear/scene/tsync/terrasync.hxx | 13 ++++--- simgear/sound/soundmgr.hxx | 17 +++++---- simgear/structure/SGPerfMon.hxx | 9 +++-- simgear/structure/event_mgr.hxx | 9 +++-- simgear/structure/subsystem_mgr.hxx | 44 +++++++++++----------- 8 files changed, 55 insertions(+), 50 deletions(-) diff --git a/simgear/misc/interpolator.hxx b/simgear/misc/interpolator.hxx index 9a5bdcfa..17f72474 100644 --- a/simgear/misc/interpolator.hxx +++ b/simgear/misc/interpolator.hxx @@ -34,8 +34,9 @@ class SGInterpolator : public SGSubsystem { public: SGInterpolator() { _list = 0; } - virtual void init() {} - virtual void update(double delta_time_sec); + + // Subsystem API. + void update(double delta_time_sec) override; // Simple method that interpolates a double property value from // its current value (default of zero) to the specified target diff --git a/simgear/props/PropertyBasedMgr.hxx b/simgear/props/PropertyBasedMgr.hxx index e058206b..1d40326a 100644 --- a/simgear/props/PropertyBasedMgr.hxx +++ b/simgear/props/PropertyBasedMgr.hxx @@ -33,9 +33,9 @@ class PropertyBasedMgr : public SGSubsystem, public SGPropertyChangeListener { public: + // Subsystem API. void init() override; void shutdown() override; - void update(double delta_time_sec) override; /** diff --git a/simgear/props/PropertyInterpolationMgr.hxx b/simgear/props/PropertyInterpolationMgr.hxx index 51ec15d7..429d2933 100644 --- a/simgear/props/PropertyInterpolationMgr.hxx +++ b/simgear/props/PropertyInterpolationMgr.hxx @@ -51,10 +51,8 @@ public: PropertyInterpolationMgr(); - /** - * Update all active interpolators. - */ - void update(double dt); + // Subsystem API. + void update(double dt) override; /** * Create a new property interpolator. diff --git a/simgear/scene/tsync/terrasync.hxx b/simgear/scene/tsync/terrasync.hxx index 214fdf5a..89400f04 100644 --- a/simgear/scene/tsync/terrasync.hxx +++ b/simgear/scene/tsync/terrasync.hxx @@ -42,12 +42,13 @@ public: SGTerraSync(); virtual ~SGTerraSync(); - virtual void init(); - virtual void shutdown(); - virtual void reinit(); - virtual void bind(); - virtual void unbind(); - virtual void update(double); + // Subsystem API. + void bind() override; + void init() override; + void reinit() override; + void shutdown() override; + void unbind() override; + void update(double) override; /// notify terrasync that the sim was repositioned, as opposed to /// us travelling in a direction. Avoid last_lat / last_lon blocking diff --git a/simgear/sound/soundmgr.hxx b/simgear/sound/soundmgr.hxx index 55e683de..0d1ab95a 100644 --- a/simgear/sound/soundmgr.hxx +++ b/simgear/sound/soundmgr.hxx @@ -52,15 +52,18 @@ public: SGSoundMgr(); ~SGSoundMgr(); - void init(); - void update(double dt); + // Subsystem API. + void init() override; + void reinit() override; + void resume() override; + void suspend() override; + void update(double dt) override; + + // Subsystem identification. + static const char* subsystemName() { return "sound"; } - void suspend(); - void resume(); void stop(); - void reinit(); - /** * Select a specific sound device. * Requires a init/reinit call before sound is actually switched. @@ -323,8 +326,6 @@ public: bool testForError(std::string s, std::string name = "sound manager"); - static const char* subsystemName() { return "sound"; }; - private: class SoundManagerPrivate; /// private implementation object diff --git a/simgear/structure/SGPerfMon.hxx b/simgear/structure/SGPerfMon.hxx index 683beb46..14745cd2 100644 --- a/simgear/structure/SGPerfMon.hxx +++ b/simgear/structure/SGPerfMon.hxx @@ -37,10 +37,11 @@ class SGPerformanceMonitor : public SGSubsystem public: SGPerformanceMonitor(SGSubsystemMgr* subSysMgr, SGPropertyNode_ptr root); - virtual void bind (void); - virtual void unbind (void); - virtual void init (void); - virtual void update (double dt); + // Subsystem API. + void bind() override; + void init() override; + void unbind() override; + void update(double dt) override; private: static void subSystemMgrHook(void* userData, const std::string& name, SampleStatistic* timeStat); diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx index ea79abcb..caf860b0 100644 --- a/simgear/structure/event_mgr.hxx +++ b/simgear/structure/event_mgr.hxx @@ -76,10 +76,11 @@ public: SGEventMgr(); ~SGEventMgr(); - virtual void init(); - virtual void update(double delta_time_sec); - virtual void unbind(); - virtual void shutdown(); + // Subsystem API. + void init() override; + void shutdown() override; + void unbind() override; + void update(double delta_time_sec) override; void setRealtimeProperty(SGPropertyNode* node) { _rtProp = node; } diff --git a/simgear/structure/subsystem_mgr.hxx b/simgear/structure/subsystem_mgr.hxx index 76b88327..a5f562d2 100644 --- a/simgear/structure/subsystem_mgr.hxx +++ b/simgear/structure/subsystem_mgr.hxx @@ -382,17 +382,18 @@ public: SGSubsystemGroup (const char *name); virtual ~SGSubsystemGroup (); + // Subsystem API. + void bind() override; + InitStatus incrementalInit() override; void init() override; - InitStatus incrementalInit () override; - void postinit () override; - void reinit () override; - void shutdown () override; - void bind () override; - void unbind () override; - void update (double delta_time_sec) override; - void suspend () override; - void resume () override; - bool is_suspended () const override; + void postinit() override; + void reinit() override; + void resume() override; + void shutdown() override; + void suspend() override; + void unbind() override; + void update(double delta_time_sec) override; + bool is_suspended() const override; virtual void set_subsystem (const std::string &name, SGSubsystem * subsystem, @@ -506,17 +507,18 @@ public: SGSubsystemMgr (const char *name); virtual ~SGSubsystemMgr (); - void init () override; - InitStatus incrementalInit () override; - void postinit () override; - void reinit () override; - void shutdown () override; - void bind () override; - void unbind () override; - void update (double delta_time_sec) override; - void suspend () override; - void resume () override; - bool is_suspended () const override; + // Subsystem API. + void bind() override; + void init() override; + InitStatus incrementalInit() override; + void postinit() override; + void reinit() override; + void resume() override; + void shutdown() override; + void suspend() override; + void unbind() override; + void update(double delta_time_sec) override; + bool is_suspended() const override; virtual void add (const char * name, SGSubsystem * subsystem,