informative discussion
|
SGSubsystem is just a class with a handful of virtual methods, virtual methods can be overridden/customized by child classes. These virtual methods are the "interface" of the class, so all objects inherited from SGSubsystem will have methods like void update(double dt)
That makes it possible to come up with different subsystems that have well-defined entry points for the sgsubsystemMgr (=manager).
Once the fg main loop is running, the main thread running the main loop will basically run a for-loop to call each registered sgsubsystem::update(double) method and pass dt (delta time) since the last update.
At initialization time, subsystems can be registered to have different update intervals (rates), as well as different parent groups - e.g. an update time of 1.00 will update a subsystem once per second, while an update time of 5.00 will only update it every 5 seconds.
Equally, some subsystems may need to be updated on a per frame basis, i.e. passing 0.00
For FDM-coupled subsystems, we can also have those updated at FDM-rate (which is interleaved with the AP/autopilot, e.g. 60-120 times per main loop iteration)
Whenever you create a new subsystem, you should inherit from SGSubsystem to obtain a child class, and implement the required methods of the interface (with ::update(double dt) being most relevant typically)
Apart from that, subsystems may have their own objects using instantiation and aggregation/composition of other classes, which may have their own update() methods, using function overloading (different signature, i.e. no double dt there)
— Hooray
|
|
Status
As of 05/2009, this is largely based on the ridge lift thread [1] .
TODO
- Deleting subsystems using the FGGlobals dtor