From: James Turner Date: Fri, 5 Nov 2010 09:19:22 +0000 (+0000) Subject: Formal shutdown interface on SGSubsystem. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;ds=sidebyside;h=5f2f95676c4b46e0c2ef3764baa2fd8c87abd238;hp=4bf16243fcdcc9b919f36cd8749dbe529cf184fe;p=simgear.git Formal shutdown interface on SGSubsystem. --- diff --git a/simgear/structure/subsystem_mgr.cxx b/simgear/structure/subsystem_mgr.cxx index 6e4dff29..387d097a 100644 --- a/simgear/structure/subsystem_mgr.cxx +++ b/simgear/structure/subsystem_mgr.cxx @@ -38,6 +38,11 @@ SGSubsystem::reinit () { } +void +SGSubsystem::shutdown () +{ +} + void SGSubsystem::bind () { @@ -141,6 +146,14 @@ SGSubsystemGroup::reinit () _members[i]->subsystem->reinit(); } +void +SGSubsystemGroup::shutdown () +{ + // reverse order to prevent order dependency problems + for (unsigned int i = _members.size(); i > 0; i--) + _members[i-1]->subsystem->shutdown(); +} + void SGSubsystemGroup::bind () { @@ -420,6 +433,15 @@ SGSubsystemMgr::reinit () _groups[i]->reinit(); } +void +SGSubsystemMgr::shutdown () +{ + // reverse order to prevent order dependency problems + for (int i = MAX_GROUPS-1; i >= 0; i--) + _groups[i]->shutdown(); +} + + void SGSubsystemMgr::bind () { diff --git a/simgear/structure/subsystem_mgr.hxx b/simgear/structure/subsystem_mgr.hxx index b36bdb9a..c49d73fd 100644 --- a/simgear/structure/subsystem_mgr.hxx +++ b/simgear/structure/subsystem_mgr.hxx @@ -169,6 +169,16 @@ public: virtual void reinit (); + /** + * Shutdown the subsystem. + * + *

Release any state associated with subsystem. Shutdown happens in + * the reverse order to init(), so this is the correct place to do + * shutdown that depends on other subsystems. + *

+ */ + virtual void shutdown (); + /** * Acquire the subsystem's property bindings. * @@ -297,6 +307,7 @@ public: virtual void init (); virtual void postinit (); virtual void reinit (); + virtual void shutdown (); virtual void bind (); virtual void unbind (); virtual void update (double delta_time_sec); @@ -392,6 +403,7 @@ public: virtual void init (); virtual void postinit (); virtual void reinit (); + virtual void shutdown (); virtual void bind (); virtual void unbind (); virtual void update (double delta_time_sec);