diff --git a/src/ATC/AIMgr.cxx b/src/ATC/AIMgr.cxx
index 871feb8b4..c0a6ec9a8 100644
--- a/src/ATC/AIMgr.cxx
+++ b/src/ATC/AIMgr.cxx
@@ -19,10 +19,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#include
+#include
+
#include
#include
-#include
#include
diff --git a/src/ATC/AIMgr.hxx b/src/ATC/AIMgr.hxx
index a186d1307..2c67eb020 100644
--- a/src/ATC/AIMgr.hxx
+++ b/src/ATC/AIMgr.hxx
@@ -22,7 +22,8 @@
#ifndef _FG_AIMGR_HXX
#define _FG_AIMGR_HXX
-#include
+#include
+
#include
#include
@@ -33,7 +34,7 @@
SG_USING_STD(list);
-class FGAIMgr : public FGSubsystem
+class FGAIMgr : public SGSubsystem
{
private:
diff --git a/src/ATC/ATC.cxx b/src/ATC/ATC.cxx
index 2a51b89a5..d8fc4b737 100644
--- a/src/ATC/ATC.cxx
+++ b/src/ATC/ATC.cxx
@@ -24,7 +24,6 @@
#include
-#include
#include
#include "ATC.hxx"
diff --git a/src/ATC/ATCDialog.cxx b/src/ATC/ATCDialog.cxx
index 9566e1da6..1a4aefa3f 100644
--- a/src/ATC/ATCDialog.cxx
+++ b/src/ATC/ATCDialog.cxx
@@ -18,10 +18,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include
+
#include
-#include
#include
-#include
#include "ATCDialog.hxx"
#include "ATC.hxx"
diff --git a/src/ATC/ATCdisplay.hxx b/src/ATC/ATCdisplay.hxx
index ba50fd6c5..c41bb72f8 100644
--- a/src/ATC/ATCdisplay.hxx
+++ b/src/ATC/ATCdisplay.hxx
@@ -27,7 +27,7 @@
# include
#endif
-#include
+#include
#include
#include
@@ -49,7 +49,7 @@ struct atcMessage {
typedef vector atcMessageList;
typedef atcMessageList::iterator atcMessageListIterator;
-class FGATCDisplay : public FGSubsystem
+class FGATCDisplay : public SGSubsystem
{
private:
diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx
index fca305417..fc300d1af 100644
--- a/src/ATC/ATCmgr.cxx
+++ b/src/ATC/ATCmgr.cxx
@@ -18,8 +18,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//#include
*/
-class FGInput : public FGSubsystem
+class FGInput : public SGSubsystem
{
public:
@@ -192,7 +192,7 @@ public:
virtual ~FGInput();
//
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
//
virtual void init ();
virtual void update (double dt);
diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx
index 8f0cfd45d..0572a0eb1 100644
--- a/src/Instrumentation/airspeed_indicator.hxx
+++ b/src/Instrumentation/airspeed_indicator.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -30,7 +29,7 @@
*
* /instrumentation/airspeed-indicator/indicated-speed-kt
*/
-class AirspeedIndicator : public FGSubsystem
+class AirspeedIndicator : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx
index 0615e021a..73c1c2c02 100644
--- a/src/Instrumentation/altimeter.hxx
+++ b/src/Instrumentation/altimeter.hxx
@@ -12,7 +12,7 @@
#endif
#include
-#include
+#include
class SGInterpTable;
@@ -31,7 +31,7 @@ class SGInterpTable;
*
* /instrumentation/altimeter/indicated-altitude-ft
*/
-class Altimeter : public FGSubsystem
+class Altimeter : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/annunciator.hxx b/src/Instrumentation/annunciator.hxx
index 8938de4c4..2834f8c25 100644
--- a/src/Instrumentation/annunciator.hxx
+++ b/src/Instrumentation/annunciator.hxx
@@ -10,8 +10,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -28,7 +27,7 @@
*
* /instrumentation/airspeed-indicator/indicated-speed-kt
*/
-class Annunciator : public FGSubsystem
+class Annunciator : public SGSubsystem
{
// timers
diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx
index db68dd98b..b71e742c2 100644
--- a/src/Instrumentation/attitude_indicator.hxx
+++ b/src/Instrumentation/attitude_indicator.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
#include "gyro.hxx"
@@ -39,7 +38,7 @@
* /instrumentation/attitude-indicator/indicated-roll-deg
* /instrumentation/attitude-indicator/tumble-norm
*/
-class AttitudeIndicator : public FGSubsystem
+class AttitudeIndicator : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/clock.hxx b/src/Instrumentation/clock.hxx
index 25fcd659f..0e35f0441 100644
--- a/src/Instrumentation/clock.hxx
+++ b/src/Instrumentation/clock.hxx
@@ -14,8 +14,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -31,7 +30,7 @@
* /instrumentation/clock/indicated-sec
* /instrumentation/clock/indicated-string
*/
-class Clock : public FGSubsystem
+class Clock : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/dme.hxx b/src/Instrumentation/dme.hxx
index c70c43ab8..39fbf2eaa 100644
--- a/src/Instrumentation/dme.hxx
+++ b/src/Instrumentation/dme.hxx
@@ -13,8 +13,7 @@
#include
#include
-
-#include
+#include
/**
@@ -37,7 +36,7 @@
* /instrumentation/dme/indicated-ground-speed-kt
* /instrumentation/dme/indicated-time-kt
*/
-class DME : public FGSubsystem
+class DME : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx
index 78025aae2..72578c61c 100644
--- a/src/Instrumentation/gps.hxx
+++ b/src/Instrumentation/gps.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -37,7 +36,7 @@
* /instrumentation/gps/indicated-track-magnetic-deg
* /instrumentation/gps/indicated-ground-speed-kt
*/
-class GPS : public FGSubsystem
+class GPS : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/heading_indicator.hxx b/src/Instrumentation/heading_indicator.hxx
index 908495adc..75b1bc5c3 100644
--- a/src/Instrumentation/heading_indicator.hxx
+++ b/src/Instrumentation/heading_indicator.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
#include "gyro.hxx"
@@ -35,7 +34,7 @@
*
* /instrumentation/heading-indicator/indicated-heading-deg
*/
-class HeadingIndicator : public FGSubsystem
+class HeadingIndicator : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/instrument_mgr.hxx b/src/Instrumentation/instrument_mgr.hxx
index f040e26c2..11649adab 100644
--- a/src/Instrumentation/instrument_mgr.hxx
+++ b/src/Instrumentation/instrument_mgr.hxx
@@ -16,8 +16,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -26,7 +25,7 @@
* In the initial draft, the instruments present are hard-coded, but they
* will soon be configurable for individual aircraft.
*/
-class FGInstrumentMgr : public FGSubsystemGroup
+class FGInstrumentMgr : public SGSubsystemGroup
{
public:
diff --git a/src/Instrumentation/mag_compass.hxx b/src/Instrumentation/mag_compass.hxx
index f16a22287..8f7aafe27 100644
--- a/src/Instrumentation/mag_compass.hxx
+++ b/src/Instrumentation/mag_compass.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -34,7 +33,7 @@
*
* /instrumentation/magnetic-compass/indicated-heading-deg
*/
-class MagCompass : public FGSubsystem
+class MagCompass : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx
index d3e3e076b..d8ed245c0 100644
--- a/src/Instrumentation/slip_skid_ball.hxx
+++ b/src/Instrumentation/slip_skid_ball.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
#include "gyro.hxx"
@@ -31,7 +30,7 @@
*
* /instrumentation/slip-skid-ball/indicated-slip-skid
*/
-class SlipSkidBall : public FGSubsystem
+class SlipSkidBall : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/turn_indicator.hxx b/src/Instrumentation/turn_indicator.hxx
index 89681cfea..5d5028cf1 100644
--- a/src/Instrumentation/turn_indicator.hxx
+++ b/src/Instrumentation/turn_indicator.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
#include "gyro.hxx"
@@ -36,7 +35,7 @@
*
* /instrumentation/turn-indicator/indicated-turn-rate
*/
-class TurnIndicator : public FGSubsystem
+class TurnIndicator : public SGSubsystem
{
public:
diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx
index 007d8ace5..f7df642e8 100644
--- a/src/Instrumentation/vertical_speed_indicator.hxx
+++ b/src/Instrumentation/vertical_speed_indicator.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -28,7 +27,7 @@
*
* /instrumentation/vertical-speed-indicator/indicated-speed-fpm
*/
-class VerticalSpeedIndicator : public FGSubsystem
+class VerticalSpeedIndicator : public SGSubsystem
{
public:
diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am
index 0a5134b1f..a5492ddb0 100644
--- a/src/Main/Makefile.am
+++ b/src/Main/Makefile.am
@@ -54,7 +54,6 @@ libMain_a_SOURCES = \
fg_init.cxx fg_init.hxx \
fg_io.cxx fg_io.hxx \
fg_props.cxx fg_props.hxx \
- fgfs.cxx fgfs.hxx \
globals.cxx globals.hxx \
logger.cxx logger.hxx \
options.cxx options.hxx \
@@ -102,7 +101,7 @@ fgfs_LDADD = \
$(CLOUD3D_LIBS) \
-lsgroute -lsgsky -lsgsound -lsgephem -lsgmaterial -lsgtgdb -lsgmodel \
-lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket -lsgprops -lsgdebug \
- -lsgmagvar -lsgmisc -lsgxml -lsgsound -lsgserial \
+ -lsgmagvar -lsgmisc -lsgxml -lsgsound -lsgserial -lsgstructure \
$(THREAD_LIBS) \
-lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul \
$(network_LIBS) \
diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx
index 6ee3eb150..588f1ab07 100644
--- a/src/Main/bootstrap.cxx
+++ b/src/Main/bootstrap.cxx
@@ -33,7 +33,7 @@
#include
#include
-#include
+#include
#include
#include STL_IOSTREAM
diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
index 69ab356f3..6769654f5 100644
--- a/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
@@ -3,7 +3,6 @@
#include // strcmp()
#include
-#include
#include STL_STRING
#include STL_FSTREAM
@@ -11,7 +10,8 @@
#include
#include
#include
-#include
+#include
+#include
#include
#include
@@ -202,7 +202,7 @@ do_reinit (const SGPropertyNode * arg)
} else {
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG( SG_GENERAL, SG_ALERT,
@@ -213,6 +213,8 @@ do_reinit (const SGPropertyNode * arg)
}
}
+ globals->get_event_mgr()->reinit();
+
return result;
}
@@ -229,7 +231,7 @@ do_suspend (const SGPropertyNode * arg)
vector subsystems = arg->getChildren("subsystem");
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
@@ -253,7 +255,7 @@ do_resume (const SGPropertyNode * arg)
vector subsystems = arg->getChildren("subsystem");
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
diff --git a/src/Main/fg_commands.hxx b/src/Main/fg_commands.hxx
index 92a75a8a6..6bd3c6e2e 100644
--- a/src/Main/fg_commands.hxx
+++ b/src/Main/fg_commands.hxx
@@ -16,7 +16,7 @@
# include
#endif
-#include
+#include
#include
/**
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index 10c522510..f308de7e8 100644
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -47,12 +47,13 @@
#endif
#include
-#include
#include STL_STRING
#include
#include
+#include
+#include
#include
#include
#include
@@ -106,7 +107,6 @@
#endif
#include
#include
-#include
#include
#include
#include
@@ -1410,6 +1410,18 @@ bool fgInitSubsystems() {
SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the event manager subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->get_event_mgr()->bind();
+ globals->get_event_mgr()->init();
+
+ // Output event stats every 60 seconds
+ globals->get_event_mgr()->add( "SGEventMgr::print_stats()",
+ globals->get_event_mgr(),
+ &SGEventMgr::print_stats,
+ 60000 );
////////////////////////////////////////////////////////////////////
// Initialize the material property subsystem.
@@ -1422,17 +1434,6 @@ bool fgInitSubsystems() {
exit(-1);
}
- ////////////////////////////////////////////////////////////////////
- // Initialize the event manager subsystem.
- ////////////////////////////////////////////////////////////////////
-
- global_events.init();
-
- // Output event stats every 60 seconds
- global_events.Register( "FGEventMgr::print_stats()",
- &global_events, &FGEventMgr::print_stats,
- 60000 );
-
////////////////////////////////////////////////////////////////////
// Initialize the scenery management subsystem.
@@ -1449,10 +1450,10 @@ bool fgInitSubsystems() {
}
// cause refresh of viewer scenery timestamps every 15 seconds...
- global_events.Register( "FGTileMgr::refresh_view_timestamps()",
- globals->get_tile_mgr(),
- &FGTileMgr::refresh_view_timestamps,
- 15000 );
+ globals->get_event_mgr()->add( "FGTileMgr::refresh_view_timestamps()",
+ globals->get_tile_mgr(),
+ &FGTileMgr::refresh_view_timestamps,
+ 15000 );
SG_LOG( SG_GENERAL, SG_DEBUG,
"Current terrain elevation after tile mgr init " <<
@@ -1477,12 +1478,6 @@ bool fgInitSubsystems() {
fgInitView();
- ////////////////////////////////////////////////////////////////////
- // Initialize the lighting subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->add_subsystem("lighting", new FGLight);
-
////////////////////////////////////////////////////////////////////
// Create and register the logger.
////////////////////////////////////////////////////////////////////
@@ -1503,7 +1498,7 @@ bool fgInitSubsystems() {
// Create and register the XML GUI.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("gui", new NewGUI, FGSubsystemMgr::INIT);
+ globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
////////////////////////////////////////////////////////////////////
@@ -1511,8 +1506,8 @@ bool fgInitSubsystems() {
////////////////////////////////////////////////////////////////////
// update the current timezone each 30 minutes
- global_events.Register( "fgUpdateLocalTime()", &fgUpdateLocalTime,
- 30*60*1000 );
+ globals->get_event_mgr()->add( "fgUpdateLocalTime()",
+ &fgUpdateLocalTime, 30*60*1000 );
////////////////////////////////////////////////////////////////////
@@ -1558,12 +1553,20 @@ bool fgInitSubsystems() {
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
// register the periodic update of the weather
- global_events.Register( "weather update", &fgUpdateWeatherDatabase,
- 30000);
+ globals->get_event_mgr()->add( "weather update",
+ &fgUpdateWeatherDatabase, 30000);
#else
globals->add_subsystem("environment", new FGEnvironmentMgr);
#endif
+
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the lighting subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->add_subsystem("lighting", new FGLight);
+
+
#ifdef FG_USE_CLOUDS_3D
////////////////////////////////////////////////////////////////////
// Initialize the 3D cloud subsystem.
@@ -1740,7 +1743,6 @@ bool fgInitSubsystems() {
globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init();
-
#ifdef FG_MPLAYER_AS
////////////////////////////////////////////////////////////////////
// Initialize multiplayer subsystem
diff --git a/src/Main/fg_io.hxx b/src/Main/fg_io.hxx
index 3f81f9417..aa377c182 100644
--- a/src/Main/fg_io.hxx
+++ b/src/Main/fg_io.hxx
@@ -26,17 +26,17 @@
#include
+#include
+
#include
#include STL_STRING
-#include "fgfs.hxx"
-
SG_USING_STD(vector);
SG_USING_STD(string);
class FGProtocol;
-class FGIO : public FGSubsystem
+class FGIO : public SGSubsystem
{
public:
FGIO();
diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx
index 0311fcd93..22b1d0901 100644
--- a/src/Main/fg_props.cxx
+++ b/src/Main/fg_props.cxx
@@ -24,7 +24,7 @@
# include
#endif
-#include
+#include
#include
#include
#include
@@ -46,7 +46,6 @@
#include
#include "globals.hxx"
-#include "fgfs.hxx"
#include "fg_props.hxx"
SG_USING_STD(istream);
diff --git a/src/Main/fgfs.cxx b/src/Main/fgfs.cxx
deleted file mode 100644
index c92e99526..000000000
--- a/src/Main/fgfs.cxx
+++ /dev/null
@@ -1,337 +0,0 @@
-#include "fgfs.hxx"
-
-#include
-#include
-
-#include "globals.hxx"
-#include "fg_props.hxx"
-
-
-
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystem
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystem::FGSubsystem ()
- : _suspended(false)
-{
-}
-
-FGSubsystem::~FGSubsystem ()
-{
-}
-
-void
-FGSubsystem::init ()
-{
-}
-
-void
-FGSubsystem::reinit ()
-{
-}
-
-void
-FGSubsystem::bind ()
-{
-}
-
-void
-FGSubsystem::unbind ()
-{
-}
-
-void
-FGSubsystem::suspend ()
-{
- _suspended = true;
-}
-
-void
-FGSubsystem::suspend (bool suspended)
-{
- _suspended = suspended;
-}
-
-void
-FGSubsystem::resume ()
-{
- _suspended = false;
-}
-
-bool
-FGSubsystem::is_suspended () const
-{
- if (!_freeze_master_node.valid())
- _freeze_master_node = fgGetNode("/sim/freeze/master", true);
- return _suspended || _freeze_master_node->getBoolValue();
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemGroup.
-////////////////////////////////////////////////////////////////////////
-
-FGSubsystemGroup::FGSubsystemGroup ()
-{
-}
-
-FGSubsystemGroup::~FGSubsystemGroup ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- delete _members[i];
-}
-
-void
-FGSubsystemGroup::init ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->init();
-}
-
-void
-FGSubsystemGroup::reinit ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->reinit();
-}
-
-void
-FGSubsystemGroup::bind ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->bind();
-}
-
-void
-FGSubsystemGroup::unbind ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->unbind();
-}
-
-void
-FGSubsystemGroup::update (double delta_time_sec)
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->update(delta_time_sec); // indirect call
-}
-
-void
-FGSubsystemGroup::suspend ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->suspend();
-}
-
-void
-FGSubsystemGroup::resume ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->resume();
-}
-
-bool
-FGSubsystemGroup::is_suspended () const
-{
- return false;
-}
-
-void
-FGSubsystemGroup::set_subsystem (const string &name, FGSubsystem * subsystem,
- double min_step_sec)
-{
- Member * member = get_member(name, true);
- if (member->subsystem != 0)
- delete member->subsystem;
- member->name = name;
- member->subsystem = subsystem;
- member->min_step_sec = min_step_sec;
-}
-
-FGSubsystem *
-FGSubsystemGroup::get_subsystem (const string &name)
-{
- Member * member = get_member(name);
- if (member != 0)
- return member->subsystem;
- else
- return 0;
-}
-
-void
-FGSubsystemGroup::remove_subsystem (const string &name)
-{
- for (unsigned int i = 0; i < _members.size(); i++) {
- if (name == _members[i]->name) {
- _members.erase(_members.begin() + i);
- return;
- }
- }
-}
-
-bool
-FGSubsystemGroup::has_subsystem (const string &name) const
-{
- return (((FGSubsystemGroup *)this)->get_member(name) != 0);
-}
-
-FGSubsystemGroup::Member *
-FGSubsystemGroup::get_member (const string &name, bool create)
-{
- for (unsigned int i = 0; i < _members.size(); i++) {
- if (_members[i]->name == name)
- return _members[i];
- }
- if (create) {
- Member * member = new Member;
- _members.push_back(member);
- return member;
- } else {
- return 0;
- }
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemGroup::Member
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystemGroup::Member::Member ()
- : name(""),
- subsystem(0),
- min_step_sec(0),
- elapsed_sec(0)
-{
-}
-
-FGSubsystemGroup::Member::Member (const Member &)
-{
- Member();
-}
-
-FGSubsystemGroup::Member::~Member ()
-{
- // FIXME: causes a crash
-// delete subsystem;
-}
-
-void
-FGSubsystemGroup::Member::update (double delta_time_sec)
-{
- elapsed_sec += delta_time_sec;
- if (elapsed_sec >= min_step_sec) {
- if (!subsystem->is_suspended()) {
- subsystem->update(elapsed_sec);
- elapsed_sec = 0;
- }
- }
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemMgr.
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystemMgr::FGSubsystemMgr ()
-{
-}
-
-FGSubsystemMgr::~FGSubsystemMgr ()
-{
-}
-
-void
-FGSubsystemMgr::init ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].init();
-}
-
-void
-FGSubsystemMgr::reinit ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].reinit();
-}
-
-void
-FGSubsystemMgr::bind ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].bind();
-}
-
-void
-FGSubsystemMgr::unbind ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].unbind();
-}
-
-void
-FGSubsystemMgr::update (double delta_time_sec)
-{
- for (int i = 0; i < MAX_GROUPS; i++) {
- _groups[i].update(delta_time_sec);
- }
-}
-
-void
-FGSubsystemMgr::suspend ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].suspend();
-}
-
-void
-FGSubsystemMgr::resume ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].resume();
-}
-
-bool
-FGSubsystemMgr::is_suspended () const
-{
- return false;
-}
-
-void
-FGSubsystemMgr::add (const char * name, FGSubsystem * subsystem,
- GroupType group, double min_time_sec)
-{
- SG_LOG(SG_GENERAL, SG_INFO, "Adding subsystem " << name);
- get_group(group)->set_subsystem(name, subsystem, min_time_sec);
-
- if (_subsystem_map.find(name) != _subsystem_map.end()) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Adding duplicate subsystem " << name);
- throw sg_exception("duplicate subsystem");
- }
- _subsystem_map[name] = subsystem;
-}
-
-FGSubsystemGroup *
-FGSubsystemMgr::get_group (GroupType group)
-{
- return &(_groups[group]);
-}
-
-FGSubsystem *
-FGSubsystemMgr::get_subsystem (const string &name)
-{
- map::iterator s =_subsystem_map.find(name);
-
- if (s == _subsystem_map.end())
- return 0;
- else
- return s->second;
-}
-
-// end of fgfs.cxx
diff --git a/src/Main/fgfs.hxx b/src/Main/fgfs.hxx
deleted file mode 100644
index bc4358931..000000000
--- a/src/Main/fgfs.hxx
+++ /dev/null
@@ -1,355 +0,0 @@
-// fgfs.hxx -- top level include file for FlightGear.
-//
-// Written by David Megginson, started 2000-12
-//
-// Copyright (C) 2000 David Megginson, david@megginson.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef __FGFS_HXX
-#define __FGFS_HXX 1
-
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#include
-
-// #ifdef SG_MATH_EXCEPTION_CLASH
-// # include
-// #endif
-
-#ifdef HAVE_WINDOWS_H
-# include
-# include
-#endif
-
-#include STL_STRING
-SG_USING_STD(string);
-
-#include
-SG_USING_STD(vector);
-
-#include
-SG_USING_STD(map);
-
-#include
-
-
-
-/**
- * Basic interface for all FlightGear subsystems.
- *
- *
This is an abstract interface that all FlightGear subsystems
- * will eventually implement. It defines the basic operations for
- * each subsystem: initialization, property binding and unbinding, and
- * updating. Interfaces may define additional methods, but the
- * preferred way of exchanging information with other subsystems is
- * through the property tree.
- *
- *
To publish information through a property, a subsystem should
- * bind it to a variable or (if necessary) a getter/setter pair in the
- * bind() method, and release the property in the unbind() method:
To reference a property (possibly) from another subsystem, there
- * are two alternatives. If the property will be referenced only
- * infrequently (say, in the init() method), then the fgGet* methods
- * declared in fg_props.hxx are the simplest:
On the other hand, if the property will be referenced frequently
- * (say, in the update() method), then the hash-table lookup required
- * by the fgGet* methods might be too expensive; instead, the
- * subsystem should obtain a reference to the actual property node in
- * its init() function and use that reference in the main loop:
The node returned will always be a pointer to SGPropertyNode,
- * and the subsystem should not delete it in its destructor
- * (the pointer belongs to the property tree, not the subsystem).
- *
- *
The program may ask the subsystem to suspend or resume
- * sim-time-dependent operations; by default, the suspend() and
- * resume() methods set the protected variable _suspended,
- * which the subsystem can reference in its update() method, but
- * subsystems may also override the suspend() and resume() methods to
- * take different actions.
This method should set up the state of the subsystem, but
- * should not bind any properties. Note that any dependencies on
- * the state of other subsystems should be placed here rather than
- * in the constructor, so that FlightGear can control the
- * initialization order.
This method should release all properties that the subsystem
- * publishes. It will be invoked by FlightGear (not the destructor)
- * just before the subsystem is removed.
FlightGear invokes this method every time the subsystem should
- * update its state.
- *
- * @param delta_time_sec The delta time, in seconds, since the last
- * update. On first update, delta time will be 0.
- */
- virtual void update (double delta_time_sec) = 0;
-
-
- /**
- * Suspend operation of this subsystem.
- *
- *
This method instructs the subsystem to suspend
- * sim-time-dependent operations until asked to resume. The update
- * method will still be invoked so that the subsystem can take any
- * non-time-dependent actions, such as updating the display.
- *
- *
It is not an error for the suspend method to be invoked when
- * the subsystem is already suspended; the invocation should simply
- * be ignored.
- */
- virtual void suspend ();
-
-
- /**
- * Suspend or resum operation of this subsystem.
- *
- * @param suspended true if the subsystem should be suspended, false
- * otherwise.
- */
- virtual void suspend (bool suspended);
-
-
- /**
- * Resume operation of this subsystem.
- *
- *
This method instructs the subsystem to resume
- * sim-time-depended operations. It is not an error for the resume
- * method to be invoked when the subsystem is not suspended; the
- * invocation should simply be ignored.
- */
- virtual void resume ();
-
-
- /**
- * Test whether this subsystem is suspended.
- *
- * @return true if the subsystem is suspended, false if it is not.
- */
- virtual bool is_suspended () const;
-
-
-protected:
-
- mutable SGPropertyNode_ptr _freeze_master_node;
- bool _suspended;
-
-};
-
-
-
-/**
- * A group of FlightGear subsystems.
- */
-class FGSubsystemGroup : public FGSubsystem
-{
-public:
-
- FGSubsystemGroup ();
- virtual ~FGSubsystemGroup ();
-
- virtual void init ();
- virtual void reinit ();
- virtual void bind ();
- virtual void unbind ();
- virtual void update (double delta_time_sec);
- virtual void suspend ();
- virtual void resume ();
- virtual bool is_suspended () const;
-
- virtual void set_subsystem (const string &name,
- FGSubsystem * subsystem,
- double min_step_sec = 0);
- virtual FGSubsystem * get_subsystem (const string &name);
- virtual void remove_subsystem (const string &name);
- virtual bool has_subsystem (const string &name) const;
-
-private:
-
- struct Member {
-
- Member ();
- Member (const Member &member);
- virtual ~Member ();
-
- virtual void update (double delta_time_sec);
-
- string name;
- FGSubsystem * subsystem;
- double min_step_sec;
- double elapsed_sec;
- };
-
- Member * get_member (const string &name, bool create = false);
-
- vector _members;
-};
-
-
-
-/**
- * Manage subsystems for FlightGear.
- *
- * This top-level subsystem will eventually manage all of the
- * subsystems in FlightGear: it broadcasts its life-cycle events
- * (init, bind, etc.) to all of the subsystems it manages. Subsystems
- * are grouped to guarantee order of initialization and execution --
- * currently, the only two groups are INIT and GENERAL, but others
- * will appear in the future.
- *
- * All subsystems are named as well as grouped, and subsystems can be
- * looked up by name and cast to the appropriate subtype when another
- * subsystem needs to invoke specialized methods.
- *
- * The subsystem manager owns the pointers to all the subsystems in
- * it.
- */
-class FGSubsystemMgr : public FGSubsystem
-{
-public:
-
- /**
- * Types of subsystem groups.
- */
- enum GroupType {
- INIT = 0,
- GENERAL,
- MAX_GROUPS
- };
-
- FGSubsystemMgr ();
- virtual ~FGSubsystemMgr ();
-
- virtual void init ();
- virtual void reinit ();
- virtual void bind ();
- virtual void unbind ();
- virtual void update (double delta_time_sec);
- virtual void suspend ();
- virtual void resume ();
- virtual bool is_suspended () const;
-
- virtual void add (const char * name,
- FGSubsystem * subsystem,
- GroupType group = GENERAL,
- double min_time_sec = 0);
-
- virtual FGSubsystemGroup * get_group (GroupType group);
-
- virtual FGSubsystem * get_subsystem(const string &name);
-
-private:
-
- FGSubsystemGroup _groups[MAX_GROUPS];
- map _subsystem_map;
-
-};
-
-
-
-#endif // __FGFS_HXX
-
-// end of fgfs.hxx
diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index 0c90fe260..4008ba180 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -21,7 +21,7 @@
// $Id$
-#include
+#include
#include
#include "globals.hxx"
@@ -41,7 +41,8 @@ FGGlobals *globals;
// Constructor
FGGlobals::FGGlobals() :
- subsystem_mgr( new FGSubsystemMgr ),
+ subsystem_mgr( new SGSubsystemMgr ),
+ event_mgr( new SGEventMgr ),
sim_time_sec( 0.0 ),
fg_root( "" ),
fg_scenery( "" ),
@@ -73,8 +74,7 @@ FGGlobals::FGGlobals() :
channel_options_list( NULL ),
scenery( NULL ),
tile_mgr( NULL ),
- io( new FGIO ),
- cur_light_params( NULL )
+ io( new FGIO )
{
}
@@ -83,6 +83,7 @@ FGGlobals::FGGlobals() :
FGGlobals::~FGGlobals()
{
delete subsystem_mgr;
+ delete event_mgr;
delete initial_state;
delete props;
delete commands;
@@ -104,13 +105,13 @@ void FGGlobals::set_fg_root (const string &root) {
}
-FGSubsystemMgr *
+SGSubsystemMgr *
FGGlobals::get_subsystem_mgr () const
{
return subsystem_mgr;
}
-FGSubsystem *
+SGSubsystem *
FGGlobals::get_subsystem (const char * name)
{
return subsystem_mgr->get_subsystem(name);
@@ -118,20 +119,48 @@ FGGlobals::get_subsystem (const char * name)
void
FGGlobals::add_subsystem (const char * name,
- FGSubsystem * subsystem,
- FGSubsystemMgr::GroupType type,
+ SGSubsystem * subsystem,
+ SGSubsystemMgr::GroupType type,
double min_time_sec)
{
subsystem_mgr->add(name, subsystem, type, min_time_sec);
}
+SGEventMgr *
+FGGlobals::get_event_mgr () const
+{
+ return event_mgr;
+}
+
+
+void
+FGGlobals::add_event (const char * name,
+ int repeat_value,
+ int initial_value)
+{
+ event_mgr->add(name, subsystem_mgr->get_subsystem(name),
+ repeat_value, initial_value);
+}
+
+void
+FGGlobals::add_event (const char * name,
+ const SGSubsystem * subsystem,
+ int repeat_value,
+ int initial_value)
+{
+ event_mgr->add(name, subsystem, repeat_value, initial_value);
+}
+
+
+
// Save the current state as the initial state.
void
FGGlobals::saveInitialState ()
{
delete initial_state;
initial_state = new SGPropertyNode();
+
if (!copyProperties(props, initial_state))
SG_LOG(SG_GENERAL, SG_ALERT, "Error saving initial state");
}
diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx
index 75b18e6b0..3104989b2 100644
--- a/src/Main/globals.hxx
+++ b/src/Main/globals.hxx
@@ -24,14 +24,18 @@
#ifndef _GLOBALS_HXX
#define _GLOBALS_HXX
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
#include
+#include
+#include
+#include
#include
#include STL_STRING
-#include "fgfs.hxx"
-
-
SG_USING_STD( vector );
SG_USING_STD( string );
@@ -84,12 +88,14 @@ class FGViewer;
/**
* Bucket for subsystem pointers representing the sim's state.
*/
+
class FGGlobals
{
private:
- FGSubsystemMgr * subsystem_mgr;
+ SGSubsystemMgr * subsystem_mgr;
+ SGEventMgr * event_mgr;
// Number of milliseconds elapsed since the start of the program.
double sim_time_sec;
@@ -185,9 +191,6 @@ private:
// Input/Ouput subsystem
FGIO *io;
- // light parameters
- FGLight *cur_light_params;
-
#ifdef FG_MPLAYER_AS
//Mulitplayer managers
FGMultiplayTxMgr *multiplayer_tx_mgr;
@@ -200,16 +203,47 @@ public:
FGGlobals();
virtual ~FGGlobals();
- virtual FGSubsystemMgr * get_subsystem_mgr () const;
+ virtual SGSubsystemMgr * get_subsystem_mgr () const;
- virtual FGSubsystem * get_subsystem (const char * name);
+ virtual SGSubsystem * get_subsystem (const char * name);
virtual void add_subsystem (const char * name,
- FGSubsystem * subsystem,
- FGSubsystemMgr::GroupType
- type = FGSubsystemMgr::GENERAL,
+ SGSubsystem * subsystem,
+ SGSubsystemMgr::GroupType
+ type = SGSubsystemMgr::GENERAL,
double min_time_sec = 0);
+ virtual SGEventMgr * get_event_mgr () const;
+
+ virtual void add_event (const char * name,
+ int repeat_value,
+ int initial_value = -1 );
+
+ virtual void add_event (const char * name,
+ const SGSubsystem * subsystem,
+ int repeat_value,
+ int initial_value = -1 );
+
+ template< typename Fun >
+ inline void add_event( const char * name,
+ const Fun& func,
+ SGEvent::interval_type repeat_value,
+ SGEvent::interval_type initial_value = -1 )
+ {
+ event_mgr->add( name, get_subsystem( name ), func,
+ repeat_value, initial_value);
+ }
+
+ template< typename Fun >
+ inline void add_event( const char * name,
+ const SGSubsystem * subsystem,
+ const Fun& func,
+ SGEvent::interval_type repeat_value,
+ SGEvent::interval_type initial_value = -1 )
+ {
+ event_mgr->add( name, subsystem, func, repeat_value, initial_value);
+ }
+
inline double get_sim_time_sec () const { return sim_time_sec; }
inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
inline void set_sim_time_sec (double t) { sim_time_sec = t; }
diff --git a/src/Main/logger.hxx b/src/Main/logger.hxx
index 4818e44f0..f1098d679 100644
--- a/src/Main/logger.hxx
+++ b/src/Main/logger.hxx
@@ -19,26 +19,25 @@
#include
#include
-#include
+#include
+#include
#include
SG_USING_STD(ostream);
SG_USING_STD(vector);
-#include "fgfs.hxx"
-
/**
* Log any property values to any number of CSV files.
*/
-class FGLogger : public FGSubsystem
+class FGLogger : public SGSubsystem
{
public:
FGLogger ();
virtual ~FGLogger ();
- // Implementation of FGSubsystem
+ // Implementation of SGSubsystem
virtual void init ();
virtual void reinit ();
virtual void bind ();
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index 0056925c2..3088b9570 100644
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -64,7 +64,6 @@
#include
#include
-#include
#include
#include
#include
@@ -133,8 +132,6 @@ bool glPointParameterIsSupported = false;
# include // -dw- for command line dialog
#endif
-FGEventMgr global_events;
-
// This is a record containing a bit of global housekeeping information
FGGeneral general;
@@ -374,9 +371,6 @@ void fgRenderFrame() {
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
- // Process/manage pending events
- global_events.update( delta_time_sec );
-
// static const SGPropertyNode *longitude
// = fgGetNode("/position/longitude-deg");
// static const SGPropertyNode *latitude
@@ -510,18 +504,18 @@ void fgRenderFrame() {
if ( skyblend ) {
/*
SG_LOG( SG_GENERAL, SG_BULK, "thesky->repaint() sky_color = "
- << cur_light_params.sky_color[0] << " "
- << cur_light_params.sky_color[1] << " "
- << cur_light_params.sky_color[2] << " "
- << cur_light_params.sky_color[3] );
+ << l->sky_color()[0] << " "
+ << l->sky_color()[1] << " "
+ << l->sky_color()[2] << " "
+ << l->sky_color()[3] );
SG_LOG( SG_GENERAL, SG_BULK, " fog = "
- << cur_light_params.fog_color[0] << " "
- << cur_light_params.fog_color[1] << " "
- << cur_light_params.fog_color[2] << " "
- << cur_light_params.fog_color[3] );
+ << l->fog_color()[0] << " "
+ << l->fog_color()[1] << " "
+ << l->fog_color()[2] << " "
+ << l->fog_color()[3] );
SG_LOG( SG_GENERAL, SG_BULK,
- " sun_angle = " << cur_light_params.sun_angle
- << " moon_angle = " << cur_light_params.moon_angle );
+ " sun_angle = " << l->sun_angle
+ << " moon_angle = " << l->moon_angle );
*/
static SGSkyColor scolor;
@@ -549,7 +543,7 @@ void fgRenderFrame() {
<< " lon = " << cur_fdm_state->get_Longitude()
<< " lat = " << cur_fdm_state->get_Latitude() );
SG_LOG( SG_GENERAL, SG_BULK,
- " sun_rot = " << cur_light_params.sun_rotation
+ " sun_rot = " << l->get_sun_rotation
<< " gst = " << SGTime::cur_time_params->getGst() );
SG_LOG( SG_GENERAL, SG_BULK,
" sun ra = " << globals->get_ephem()->getSunRightAscension()
@@ -1019,6 +1013,8 @@ static void fgMainLoop( void ) {
SGTime *t = globals->get_time_params();
+ globals->get_event_mgr()->update(delta_time_sec);
+
SGLocation * acmodel_location = 0;
if(cur_fdm_state->getACModel() != 0) {
acmodel_location = (SGLocation *) cur_fdm_state->getACModel()->get3DModel()->getSGLocation();
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index 8e8b228f3..53daa5c80 100644
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
@@ -26,7 +26,7 @@
#endif
#include
-#include
+#include
#include
#include // rint()
diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx
index 1aa49a366..30f17a0d0 100644
--- a/src/Main/viewer.hxx
+++ b/src/Main/viewer.hxx
@@ -34,12 +34,11 @@
#include
#include
+#include
#include
#include // plib include
-#include "fgfs.hxx"
-
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9
@@ -49,7 +48,7 @@ enum fgViewType {
};
// Define a structure containing view information
-class FGViewer : public FGSubsystem {
+class FGViewer : public SGSubsystem {
public:
@@ -74,7 +73,7 @@ public:
virtual ~FGViewer( void );
//////////////////////////////////////////////////////////////////////
- // Part 1: standard FGSubsystem implementation.
+ // Part 1: standard SGSubsystem implementation.
//////////////////////////////////////////////////////////////////////
virtual void init ();
diff --git a/src/Main/viewmgr.hxx b/src/Main/viewmgr.hxx
index f5812db12..b4a4fbf0e 100644
--- a/src/Main/viewmgr.hxx
+++ b/src/Main/viewmgr.hxx
@@ -31,6 +31,7 @@
#include
+#include
#ifdef HAVE_CONFIG_H
# include
@@ -38,14 +39,13 @@
#include
-#include "fgfs.hxx"
#include "viewer.hxx"
SG_USING_STD(vector);
// Define a structure containing view information
-class FGViewMgr : public FGSubsystem
+class FGViewMgr : public SGSubsystem
{
public:
diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx
index 7096473e8..e14c6bd26 100644
--- a/src/Model/acmodel.cxx
+++ b/src/Model/acmodel.cxx
@@ -14,7 +14,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Model/acmodel.hxx b/src/Model/acmodel.hxx
index 0e6fe2235..cf337bd5e 100644
--- a/src/Model/acmodel.hxx
+++ b/src/Model/acmodel.hxx
@@ -15,7 +15,7 @@
SG_USING_STD(string);
SG_USING_STD(vector);
-#include // for FGSubsystem
+#include // for SGSubsystem
// Don't pull in the headers, since we don't need them here.
@@ -24,7 +24,7 @@ class ssgSelector;
class SGModelPlacement;
-class FGAircraftModel : public FGSubsystem
+class FGAircraftModel : public SGSubsystem
{
public:
diff --git a/src/Model/model_panel.cxx b/src/Model/model_panel.cxx
index 492b39d29..1c9994ed7 100644
--- a/src/Model/model_panel.cxx
+++ b/src/Model/model_panel.cxx
@@ -17,7 +17,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Model/modelmgr.hxx b/src/Model/modelmgr.hxx
index 664e48425..41376f47d 100644
--- a/src/Model/modelmgr.hxx
+++ b/src/Model/modelmgr.hxx
@@ -13,8 +13,7 @@
#include
#include // for SG_USING_STD
-
-#include // for FGSubsystem
+#include
SG_USING_STD(vector);
@@ -27,7 +26,7 @@ class SGModelPlacement;
/**
* Manage a list of user-specified models.
*/
-class FGModelMgr : public FGSubsystem
+class FGModelMgr : public SGSubsystem
{
public:
diff --git a/src/Network/generic.cxx b/src/Network/generic.cxx
index 7df1220d9..062ad9542 100644
--- a/src/Network/generic.cxx
+++ b/src/Network/generic.cxx
@@ -23,7 +23,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Network/httpd.cxx b/src/Network/httpd.cxx
index b020d89f4..94a5a9532 100644
--- a/src/Network/httpd.cxx
+++ b/src/Network/httpd.cxx
@@ -39,7 +39,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Network/props.cxx b/src/Network/props.cxx
index 9d4fdc182..7268f6f63 100644
--- a/src/Network/props.cxx
+++ b/src/Network/props.cxx
@@ -29,7 +29,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Replay/replay.hxx b/src/Replay/replay.hxx
index 41f1a4a62..499b9c349 100644
--- a/src/Replay/replay.hxx
+++ b/src/Replay/replay.hxx
@@ -34,10 +34,10 @@
#include
#include
+#include
#include
#include
-#include
SG_USING_STD(deque);
@@ -60,7 +60,7 @@ typedef deque < FGReplayData > replay_list_type;
*
*/
-class FGReplay : public FGSubsystem
+class FGReplay : public SGSubsystem
{
public:
diff --git a/src/Scenery/scenery.hxx b/src/Scenery/scenery.hxx
index 4d506e4b7..020405f83 100644
--- a/src/Scenery/scenery.hxx
+++ b/src/Scenery/scenery.hxx
@@ -33,13 +33,12 @@
#include
#include
+#include
#include
-#include
-
// Define a structure containing global scenery parameters
-class FGScenery : public FGSubsystem {
+class FGScenery : public SGSubsystem {
// center of current scenery chunk
Point3D center;
@@ -74,7 +73,7 @@ public:
FGScenery();
~FGScenery();
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
void init ();
void bind ();
void unbind ();
diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx
index f1046c552..5467f6a7a 100644
--- a/src/Scenery/tilemgr.cxx
+++ b/src/Scenery/tilemgr.cxx
@@ -33,7 +33,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Scripting/scriptmgr.hxx b/src/Scripting/scriptmgr.hxx
index f52182488..cd5aacbe2 100644
--- a/src/Scripting/scriptmgr.hxx
+++ b/src/Scripting/scriptmgr.hxx
@@ -11,8 +11,7 @@
#endif
#include // for SG_USING_STD
-
-#include
+#include
class pslExtension;
@@ -32,7 +31,7 @@ class pslExtension;
* get_property(name) - get a property value
* set_property(name, value) - set a property value
*/
-class FGScriptMgr : public FGSubsystem
+class FGScriptMgr : public SGSubsystem
{
public:
diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx
index 939e2c8c6..93e8b779b 100644
--- a/src/Sound/fg_fx.cxx
+++ b/src/Sound/fg_fx.cxx
@@ -26,7 +26,7 @@
#endif
#include
-#include
+#include
#ifdef __BORLANDC__
# define exception c_exception
#endif
diff --git a/src/Sound/fg_fx.hxx b/src/Sound/fg_fx.hxx
index a28ca9a7b..0cc29dc39 100644
--- a/src/Sound/fg_fx.hxx
+++ b/src/Sound/fg_fx.hxx
@@ -24,7 +24,7 @@
#ifndef __FGFX_HXX
#define __FGFX_HXX 1
-#include
+#include
class SGSound;
@@ -35,7 +35,7 @@ class SGSound;
* on current flight conditions. The sound manager must be initialized
* before this object is.
*/
-class FGFX : public FGSubsystem
+class FGFX : public SGSubsystem
{
public:
diff --git a/src/Systems/electrical.cxx b/src/Systems/electrical.cxx
index 4905dbeb4..b069407c4 100644
--- a/src/Systems/electrical.cxx
+++ b/src/Systems/electrical.cxx
@@ -21,7 +21,7 @@
// $Id$
-#include
+#include
#include
#include
diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx
index 9761a955c..fee71cf0b 100644
--- a/src/Systems/electrical.hxx
+++ b/src/Systems/electrical.hxx
@@ -39,8 +39,7 @@ SG_USING_STD(string);
SG_USING_STD(vector);
#include
-
-#include
+#include
// Forward declaration
@@ -184,7 +183,7 @@ public:
*
*/
-class FGElectricalSystem : public FGSubsystem
+class FGElectricalSystem : public SGSubsystem
{
public:
diff --git a/src/Systems/pitot.hxx b/src/Systems/pitot.hxx
index 0024f2882..80be710f0 100644
--- a/src/Systems/pitot.hxx
+++ b/src/Systems/pitot.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -33,7 +32,7 @@
*
* /systems/pitot[0]/total-pressure-inhg
*/
-class PitotSystem : public FGSubsystem
+class PitotSystem : public SGSubsystem
{
public:
diff --git a/src/Systems/static.hxx b/src/Systems/static.hxx
index df7c65020..56a0a4ed1 100644
--- a/src/Systems/static.hxx
+++ b/src/Systems/static.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -31,7 +30,7 @@
* TODO: support multiple static ports and specific locations
* TODO: support alternate air with errors
*/
-class StaticSystem : public FGSubsystem
+class StaticSystem : public SGSubsystem
{
public:
diff --git a/src/Systems/system_mgr.hxx b/src/Systems/system_mgr.hxx
index 544b1e30a..02c102a7e 100644
--- a/src/Systems/system_mgr.hxx
+++ b/src/Systems/system_mgr.hxx
@@ -16,8 +16,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -26,7 +25,7 @@
* In the initial draft, the systems present are hard-coded, but they
* will soon be configurable for individual aircraft.
*/
-class FGSystemMgr : public FGSubsystemGroup
+class FGSystemMgr : public SGSubsystemGroup
{
public:
diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx
index 3087c4633..a18036c77 100644
--- a/src/Systems/vacuum.hxx
+++ b/src/Systems/vacuum.hxx
@@ -12,8 +12,7 @@
#endif
#include
-
-#include
+#include
/**
@@ -31,7 +30,7 @@
*
* /systems/vacuum[n]/suction-inhg
*/
-class VacuumSystem : public FGSubsystem
+class VacuumSystem : public SGSubsystem
{
public:
diff --git a/src/Time/FGEventMgr.cxx b/src/Time/FGEventMgr.cxx
deleted file mode 100644
index f9cc429a1..000000000
--- a/src/Time/FGEventMgr.cxx
+++ /dev/null
@@ -1,217 +0,0 @@
-//
-// FGEventMgr.cxx -- Event Manager
-//
-// Written by Bernie Bright, started April 2002.
-//
-// Copyright (C) 2002 Curtis L. Olson - curt@me.umn.edu
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#include
-#include
-
-#include "FGEventMgr.hxx"
-
-FGEventMgr::FGEvent::FGEvent()
- : name_(""),
- callback_(0),
- repeat_value_(0),
- initial_value_(0),
- ms_to_go_(0),
- cum_time(0),
- min_time(100000),
- max_time(0),
- count(0)
-{
-}
-
-FGEventMgr::FGEvent::FGEvent( const char* name,
- fgCallback* cb,
- interval_type repeat_value,
- interval_type initial_value )
- : name_(name),
- callback_(cb),
- repeat_value_(repeat_value),
- initial_value_(initial_value),
- //ms_to_go_(repeat_value_),
- cum_time(0),
- min_time(100000),
- max_time(0),
- count(0)
-{
- if (initial_value_ < 0)
- {
- this->run();
- ms_to_go_ = repeat_value_;
- }
- else
- {
- ms_to_go_ = initial_value_;
- }
-}
-
-
-FGEventMgr::FGEvent::~FGEvent()
-{
- //delete callback_;
-}
-
-void
-FGEventMgr::FGEvent::run()
-{
- SGTimeStamp start_time;
- SGTimeStamp finish_time;
-
- start_time.stamp();
-
- // run the event
- (*callback_)();
-
- finish_time.stamp();
-
- ++count;
-
- unsigned long duration = finish_time - start_time;
-
- cum_time += duration;
-
- if ( duration < min_time ) {
- min_time = duration;
- }
-
- if ( duration > max_time ) {
- max_time = duration;
- }
-}
-
-void
-FGEventMgr::FGEvent::print_stats() const
-{
- SG_LOG( SG_EVENT, SG_INFO,
- " " << name_
- << " int=" << repeat_value_ / 1000.0
- << " cum=" << cum_time
- << " min=" << min_time
- << " max=" << max_time
- << " count=" << count
- << " ave=" << cum_time / (double)count );
-}
-
-FGEventMgr::FGEventMgr()
-{
-}
-
-FGEventMgr::~FGEventMgr()
-{
-}
-
-void
-FGEventMgr::init()
-{
- SG_LOG( SG_EVENT, SG_INFO, "Initializing event manager" );
-
- event_table.clear();
-}
-
-void
-FGEventMgr::bind()
-{
-}
-
-void
-FGEventMgr::unbind()
-{
-}
-
-void
-FGEventMgr::update( double dt )
-{
- int dt_ms = int(dt * 1000);
-
- if (dt_ms < 0)
- {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "FGEventMgr::update() called with negative delta T" );
- return;
- }
-
- int min_value = 0;
- event_container_type::iterator first = event_table.begin();
- event_container_type::iterator last = event_table.end();
- event_container_type::iterator event = event_table.end();
-
- // Scan all events. Run one whose interval has expired.
- while (first != last)
- {
- if (first->update( dt_ms ))
- {
- if (first->value() < min_value)
- {
- // Select event with largest negative value.
- // Its been waiting longest.
- min_value = first->value();
- event = first;
- }
- }
- ++first;
- }
-
- if (event != last)
- {
- event->run();
-
- if (event->repeat_value() > 0)
- {
- event->reset();
- }
- else
- {
- SG_LOG( SG_GENERAL, SG_DEBUG, "Deleting event " << event->name() );
- event_table.erase( event );
- }
- }
-}
-
-void
-FGEventMgr::Register( const FGEvent& event )
-{
- event_table.push_back( event );
-
- SG_LOG( SG_EVENT, SG_INFO, "Registered event " << event.name()
- << " to run every " << event.repeat_value() << "ms" );
-}
-
-void
-FGEventMgr::print_stats() const
-{
- SG_LOG( SG_EVENT, SG_INFO, "" );
- SG_LOG( SG_EVENT, SG_INFO, "Event Stats" );
- SG_LOG( SG_EVENT, SG_INFO, "-----------" );
-
- event_container_type::const_iterator first = event_table.begin();
- event_container_type::const_iterator last = event_table.end();
- for (; first != last; ++first)
- {
- first->print_stats();
- }
-
- SG_LOG( SG_EVENT, SG_INFO, "" );
-}
diff --git a/src/Time/FGEventMgr.hxx b/src/Time/FGEventMgr.hxx
deleted file mode 100644
index 54ec6ae7b..000000000
--- a/src/Time/FGEventMgr.hxx
+++ /dev/null
@@ -1,187 +0,0 @@
-// FGEventMgr.hxx -- Flight Gear periodic event scheduler
-//
-// Written by Curtis Olson, started December 1997.
-// Modified by Bernie Bright, April 2002.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-#ifndef FG_EVENT_MGR_H_INCLUDED
-#define FG_EVENT_MGR_H_INCLUDED 1
-
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-
-SG_USING_STD(vector);
-SG_USING_STD(string);
-
-/**
- *
- */
-class FGEventMgr : public FGSubsystem
-{
-public:
-
- typedef int interval_type;
-
-private:
-
- /**
- *
- */
- class FGEvent
- {
- public:
- /**
- *
- */
- FGEvent();
-
- FGEvent( const char* desc,
- fgCallback* cb,
- interval_type repeat_value,
- interval_type initial_value );
-
- /**
- *
- */
- ~FGEvent();
-
- /**
- *
- */
- void reset()
- {
- ms_to_go_ = repeat_value_;
- }
-
- /**
- * Execute this event's callback.
- */
- void run();
-
- string name() const { return name_; }
- interval_type repeat_value() const { return repeat_value_; }
- int value() const { return ms_to_go_; }
-
- /**
- * Display event statistics.
- */
- void print_stats() const;
-
- /**
- * Update the elapsed time for this event.
- * @param dt_ms elapsed time in milliseconds.
- * @return true if elapsed time has expired.
- */
- bool update( int dt_ms )
- {
- ms_to_go_ -= dt_ms;
- return ms_to_go_ <= 0;
- }
-
- private:
- string name_;
- fgCallback* callback_;
- interval_type repeat_value_;
- interval_type initial_value_;
- int ms_to_go_;
-
- unsigned long cum_time; // cumulative processor time of this event
- unsigned long min_time; // time of quickest execution
- unsigned long max_time; // time of slowest execution
- unsigned long count; // number of times executed
- };
-
-public:
- FGEventMgr();
- ~FGEventMgr();
-
- /**
- * Initialize the scheduling subsystem.
- */
- void init();
-
- void bind();
-
- void unbind();
-
- /*
- * Update the elapsed time for all events.
- * @param dt elapsed time in seconds.
- */
- void update( double dt );
-
- /**
- * Register a free standing function to be executed some time in the future.
- * @param desc A brief description of this callback for logging.
- * @param cb The callback function to be executed.
- * @param repeat_value repetition rate in milliseconds.
- * @param initial_value initial delay value in milliseconds. A value of
- * -1 means run immediately.
- */
- template< typename Fun >
- void Register( const char* name,
- const Fun& f,
- interval_type repeat_value,
- interval_type initial_value = -1 )
- {
- this->Register( FGEvent( name,
- make_callback(f),
- repeat_value,
- initial_value ) );
- }
-
- template< class ObjPtr, typename MemFn >
- void Register( const char* name,
- const ObjPtr& p,
- MemFn pmf,
- interval_type repeat_value,
- interval_type initial_value = -1 )
- {
- this->Register( FGEvent( name,
- make_callback(p,pmf),
- repeat_value,
- initial_value ) );
- }
-
- /**
- * Display statistics for all registered events.
- */
- void print_stats() const;
-
-private:
- void Register( const FGEvent& event );
-
-private:
-
- typedef vector< FGEvent > event_container_type;
-
- // Registered events.
- event_container_type event_table;
-};
-
-extern FGEventMgr global_events;
-
-#endif //FG_ EVENT_MGR_H_INCLUDED
diff --git a/src/Time/Makefile.am b/src/Time/Makefile.am
index 02e4ef5d3..41180d3a7 100644
--- a/src/Time/Makefile.am
+++ b/src/Time/Makefile.am
@@ -1,7 +1,6 @@
noinst_LIBRARIES = libTime.a
libTime_a_SOURCES = \
- FGEventMgr.cxx FGEventMgr.hxx \
fg_timer.cxx fg_timer.hxx \
light.cxx light.hxx \
moonpos.cxx moonpos.hxx \
diff --git a/src/Time/light.hxx b/src/Time/light.hxx
index 864668d00..2a24f0b5d 100644
--- a/src/Time/light.hxx
+++ b/src/Time/light.hxx
@@ -42,12 +42,13 @@
#include // plib include
+#include
#include
#include
// Define a structure containing the global lighting parameters
-class FGLight : public FGSubsystem
+class FGLight : public SGSubsystem
{
private: