From: ehofman Date: Sat, 11 Jun 2005 08:39:26 +0000 (+0000) Subject: Melchior FRANZ: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5d34eb12e07235fc56d6a5e496b0c2e208fd7381;p=simgear.git Melchior FRANZ: This is the more elegant solution that Andy had proposed in a response to my RFC on Nasal initialization code in joystick configuration files. As Nasal is initialized last (for good reason), subsystem can currently not use it for initializing. postinit() is called on all subsystems after all have been initialized. --- diff --git a/simgear/structure/subsystem_mgr.cxx b/simgear/structure/subsystem_mgr.cxx index 8b1d5ea4..9ae7d706 100644 --- a/simgear/structure/subsystem_mgr.cxx +++ b/simgear/structure/subsystem_mgr.cxx @@ -25,6 +25,11 @@ SGSubsystem::init () { } +void +SGSubsystem::postinit () +{ +} + void SGSubsystem::reinit () { @@ -87,6 +92,13 @@ SGSubsystemGroup::init () _members[i]->subsystem->init(); } +void +SGSubsystemGroup::postinit () +{ + for (unsigned int i = 0; i < _members.size(); i++) + _members[i]->subsystem->postinit(); +} + void SGSubsystemGroup::reinit () { @@ -250,6 +262,13 @@ SGSubsystemMgr::init () _groups[i].init(); } +void +SGSubsystemMgr::postinit () +{ + for (int i = 0; i < MAX_GROUPS; i++) + _groups[i].postinit(); +} + void SGSubsystemMgr::reinit () { diff --git a/simgear/structure/subsystem_mgr.hxx b/simgear/structure/subsystem_mgr.hxx index cd612335..03cbbb8d 100644 --- a/simgear/structure/subsystem_mgr.hxx +++ b/simgear/structure/subsystem_mgr.hxx @@ -140,6 +140,18 @@ public: virtual void init (); + /** + * Initialize parts that depend on other subsystems having been initialized. + * + *

This method should set up all parts that depend on other + * subsystems. One example is the scripting/Nasal subsystem, which + * is initialized last. So, if a subsystem wants to execute Nasal + * code in subsystem-specific configuration files, it has to do that + * in its postinit() method.

+ */ + virtual void postinit (); + + /** * Reinitialize the subsystem. * @@ -243,6 +255,7 @@ public: virtual ~SGSubsystemGroup (); virtual void init (); + virtual void postinit (); virtual void reinit (); virtual void bind (); virtual void unbind (); @@ -315,6 +328,7 @@ public: virtual ~SGSubsystemMgr (); virtual void init (); + virtual void postinit (); virtual void reinit (); virtual void bind (); virtual void unbind ();