Howto talk:Create new subsystems: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (Switch to the {{forum link}} template for all forum links.) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
= informative discussion = | |||
{{cquote|<nowiki>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)</nowiki>|<nowiki>Hooray</nowiki>}} | |||
= Status = | = Status = | ||
As of 05/2009, this is largely based on the ridge lift thread | As of 05/2009, this is largely based on the ridge lift thread {{forum link|t=3377}}. | ||
= TODO = | = TODO = | ||
* Deleting subsystems using the FGGlobals dtor | * Deleting subsystems using the FGGlobals dtor |
Latest revision as of 07:48, 11 June 2019
informative discussion
Status
As of 05/2009, this is largely based on the ridge lift thread [1] .
TODO
- Deleting subsystems using the FGGlobals dtor