FlightGear next
component.hxx
Go to the documentation of this file.
1// component.hxx - Base class for autopilot components
2//
3// Written by Torsten Dreyer
4// Based heavily on work created by Curtis Olson, started January 2004.
5//
6// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
7// Copyright (C) 2010 Torsten Dreyer - Torsten (at) t3r (dot) de
8//
9// This program is free software; you can redistribute it and/or
10// modify it under the terms of the GNU General Public License as
11// published by the Free Software Foundation; either version 2 of the
12// License, or (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22//
23#pragma once
24
25#include <simgear/structure/subsystem_mgr.hxx>
26#include <simgear/props/propsfwd.hxx>
27
28namespace FGXMLAutopilot {
29
33class Component : public SGSubsystem
34{
35private:
36 SGSharedPtr<const SGCondition> _condition;
37 SGPropertyNode_ptr _enable_prop;
38 std::string * _enable_value;
39 bool _enabled;
40
41protected:
42 virtual bool configure( SGPropertyNode& cfg_node,
43 const std::string& cfg_name,
44 SGPropertyNode& prop_root );
45
54 virtual void update( bool firstTime, double dt ) = 0;
55
60 virtual void disabled( double dt ) {}
61
66 bool _debug;
67
68
74
75public:
79 Component();
80
84 virtual ~Component();
85
86 // Subsystem API.
87 void update(double dt) override;
88
97 virtual bool configure( SGPropertyNode& prop_root,
98 SGPropertyNode& cfg );
99
117 bool isPropertyEnabled();
118};
119
120} // of namespace FGXMLAutopilot
121
bool _honor_passive
a (historic) flag signalling the derived class that it should compute it's internal state but shall n...
Definition component.hxx:73
virtual void update(bool firstTime, double dt)=0
pure virtual function to be implemented by the derived classes.
virtual bool configure(SGPropertyNode &cfg_node, const std::string &cfg_name, SGPropertyNode &prop_root)
Definition component.cxx:67
virtual void disabled(double dt)
overideable method being called from the update() method if this component is disabled.
Definition component.hxx:60
Component()
A constructor for an empty Component.
Definition component.cxx:30
bool isPropertyEnabled()
check if this component is enabled as configured in the <enable> section
virtual ~Component()
virtual destructor to clean up resources
Definition component.cxx:38
bool _debug
debug flag, true if this component should generate some useful output on every iteration
Definition component.hxx:66