# include <config.h>
#endif
-#include <string.h>
-#include <stdio.h>
+#include <string>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#include "Include/compiler.h"
+
+#include STL_ALGORITHM
+#include STL_FUNCTIONAL
+
+#ifdef FG_HAVE_STD_INCLUDES
+# include <cstdio>
+# ifdef HAVE_STDLIB_H
+# include <cstdlib>
+# endif
+#else
+# include <stdio.h>
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
#endif
#if defined( HAVE_WINDOWS_H ) && defined(__MWERKS__)
// contains milliseconds
#endif
-#if defined( linux ) || defined( __FreeBSD__ )
-# define _G_NO_EXTERN_TEMPLATES
-#endif
-
-#include "Include/fg_stl_config.h"
-#include STL_ALGORITHM
-#include STL_FUNCTIONAL
-
#include <Debug/logstream.hxx>
#include "event.hxx"
+FG_USING_STD(for_each);
+FG_USING_STD(mem_fun);
fgEVENT_MGR global_events;
fgEVENT::fgEVENT( const string& desc,
const fgCallback& cb,
- EventState _status,
- int _interval )
+ EventState evt_status,
+ int evt_interval )
: description(desc),
event_cb(cb.clone()),
- status(_status),
- interval(_interval),
+ status(evt_status),
+ interval(evt_interval),
cum_time(0),
min_time(100000),
max_time(0),
{
}
+#if 0
fgEVENT::fgEVENT( const fgEVENT& evt )
: description(evt.description),
-#ifdef _FG_NEED_AUTO_PTR
- // Ugly - cast away const until proper auto_ptr implementation.
- event_cb((auto_ptr<fgCallback>&)(evt.event_cb)),
-#else
event_cb(evt.event_cb),
-#endif
status(evt.status),
interval(evt.interval),
last_run(evt.last_run),
{
}
+fgEVENT&
+fgEVENT::operator= ( const fgEVENT& evt )
+{
+ if ( this != &evt )
+ {
+ description = evt.description;
+ event_cb = evt.event_cb;
+ status = evt.status;
+ interval = evt.interval;
+ last_run = evt.last_run;
+ current = evt.current;
+ next_run = evt.next_run;
+ cum_time = evt.cum_time;
+ min_time = evt.min_time;
+ max_time = evt.max_time;
+ count = evt.count;
+ }
+ return *this;
+}
+#endif
+
fgEVENT::~fgEVENT()
{
-// cout << "fgEVENT::~fgEVENT" << endl;
+ delete event_cb;
}
void
fgEVENT::EventState status,
int interval )
{
- fgEVENT e( desc, cb, status, interval );
+ fgEVENT* e = new fgEVENT( desc, cb, status, interval );
FG_LOG( FG_EVENT, FG_INFO, "Registering event: " << desc );
// Actually run the event
- e.run();
+ e->run();
// Now add to event_table
event_table.push_back(e);
FG_LOG( FG_EVENT, FG_INFO, "Event Stats" );
FG_LOG( FG_EVENT, FG_INFO, "-----------" );
+ ConstEventIterator first = event_table.begin();
+ ConstEventIterator last = event_table.end();
+ while ( first != last )
+ {
+ (*first)->PrintStats();
+ ++first;
+ }
+#if 0 // msvc++ 6.0 barfs at mem_fun()
for_each( event_table.begin(),
event_table.end(),
- mem_fun_ref( &fgEVENT::PrintStats ));
-
+ mem_fun( &fgEVENT::PrintStats ) );
+#endif
FG_LOG( FG_EVENT, FG_INFO, "");
}
// while ( current != last ) {
for ( i = 0; i < size; i++ ) {
// e = *current++;
- e_ptr = &event_table[i];
+ e_ptr = event_table[i];
if ( e_ptr->status == fgEVENT::FG_EVENT_READY ) {
FG_LOG( FG_EVENT, FG_DEBUG,
" Item " << i << " current " << cur_time.get_seconds()
// Destructor
fgEVENT_MGR::~fgEVENT_MGR( void ) {
+ EventIterator first = event_table.begin();
+ EventIterator last = event_table.end();
+ for ( ; first != last; ++first )
+ {
+ delete (*first);
+ }
+
+ run_queue.erase( run_queue.begin(), run_queue.end() );
+ event_table.erase( event_table.begin(), event_table.end() );
}
// $Log$
+// Revision 1.14 1999/01/07 20:25:32 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.13 1998/12/04 01:32:46 curt
// Converted "struct fg_timestamp" to "class fgTIMESTAMP" and added some
// convenience inline operators.
#endif
-#if defined ( __sun__ ) || defined ( __sgi )
-extern "C" void *memmove(void *, const void *, size_t);
-extern "C" void *memset(void *, int, size_t);
-#endif
-
+#include "Include/compiler.h"
+#include "Include/fg_callback.hxx"
#include <deque> // STL double ended queue
#include <list> // STL list
#include <string>
-#include "Include/fg_stl_config.h"
-
-#ifdef FG_NEED_AUTO_PTR
-# include "Include/auto_ptr.hxx"
-#else
-# include <memory>
-#endif
-
-#include "Include/fg_callback.hxx"
-
-#ifdef NEEDNAMESPACESTD
-using namespace std;
-#endif
+FG_USING_STD(deque);
+FG_USING_STD(list);
+FG_USING_STD(string);
#include "fg_time.hxx"
#include "timestamp.hxx"
FG_EVENT_QUEUED = 2
};
+ friend class fgEVENT_MGR;
+
fgEVENT() {} // Required by deque<>.
fgEVENT( const string& desc,
const fgCallback& cb,
- EventState _status,
- int _interval );
-
- fgEVENT( const fgEVENT& evt );
+ EventState evt_status,
+ int evt_interval );
~fgEVENT();
// void PrintStats() const;
int PrintStats() const;
-public:
+private:
+ // not defined
+ fgEVENT( const fgEVENT& evt );
+ fgEVENT& operator= ( const fgEVENT& evt );
+
+private:
string description;
// The callback object.
- // We wrap it in an auto_ptr<> because deque<> calls our copy ctor
- // and dtor when inserting and removing.
- auto_ptr<fgCallback> event_cb;
+ fgCallback* event_cb;
EventState status; // status flag
class fgEVENT_MGR {
// Event table
- deque < fgEVENT > event_table;
+ typedef deque < fgEVENT* > EventContainer;
+ typedef EventContainer::iterator EventIterator;
+ typedef EventContainer::const_iterator ConstEventIterator;
+
+ EventContainer event_table;
// Run Queue
- list < fgEVENT * > run_queue;
+ typedef list < fgEVENT * > RunContainer;
+
+ RunContainer run_queue;
public:
// $Log$
+// Revision 1.15 1999/01/07 20:25:33 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.14 1998/12/05 14:21:28 curt
// Moved struct fg_timestamp to class fgTIMESTAMP and moved it's definition
// to it's own file, timestamp.hxx.
# include <config.h>
#endif
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
+#include "Include/compiler.h"
+#ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# include <cstdio>
+# include <cstdlib>
+# include <ctime>
+#else
+# include <math.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <time.h>
+#endif
#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h> // for ftime() and struct timeb
long int offset = -(timezone / 3600 - daylight);
- FG_LOG( FG_EVENT, FG_DEBUG,
- " Raw time zone offset = " << timezone );
- FG_LOG( FG_EVENT, FG_DEBUG,
- " Daylight Savings = " << daylight );
- FG_LOG( FG_EVENT, FG_DEBUG,
- " Local hours from GMT = " << offset);
+ FG_LOG( FG_EVENT, FG_DEBUG, " Raw time zone offset = " << timezone );
+ FG_LOG( FG_EVENT, FG_DEBUG, " Daylight Savings = " << daylight );
+ FG_LOG( FG_EVENT, FG_DEBUG, " Local hours from GMT = " << offset );
long int start_gmt = start - timezone + (daylight * 3600);
# endif // ! defined ( MK_TIME_IS_GMT )
}
+static char*
+format_time( const struct tm* p, char* buf )
+{
+ sprintf( buf, "%d/%d/%2d %d:%02d:%02d",
+ p->tm_mon, p->tm_mday, p->tm_year,
+ p->tm_hour, p->tm_min, p->tm_sec);
+ return buf;
+}
// return a courser but cheaper estimate of sidereal time
double sidereal_course(fgTIME *t, double lng) {
struct tm *gmt;
time_t start_gmt, now;
double diff, part, days, hours, lst;
+ char tbuf[64];
gmt = t->gmt;
now = t->cur_time;
start_gmt = get_start_gmt(gmt->tm_year);
- FG_LOG( FG_EVENT, FG_DEBUG,
- " COURSE: GMT = "
- << gmt->tm_mon << "/" << gmt->tm_mday << "/" << gmt->tm_year
- << " "
- << gmt->tm_hour << ":" << gmt->tm_min << ":" << gmt->tm_sec );
-
- FG_LOG( FG_EVENT, FG_DEBUG, " March 21 noon (GMT) = " << start_gmt);
+ FG_LOG( FG_EVENT, FG_DEBUG, " COURSE: GMT = " << format_time(gmt, tbuf) );
+ FG_LOG( FG_EVENT, FG_DEBUG, " March 21 noon (GMT) = " << start_gmt );
diff = (now - start_gmt) / (3600.0 * 24.0);
// $Log$
+// Revision 1.28 1999/01/07 20:25:34 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.27 1998/12/11 20:26:55 curt
// #include tweaks.
//
#endif
#include <GL/glut.h>
-#include <time.h>
+
+#include "Include/compiler.h"
+#ifdef FG_HAVE_STD_INCLUDES
+# include <ctime>
+#else
+# include <time.h>
+#endif
#include <Flight/flight.hxx>
// $Log$
+// Revision 1.12 1999/01/07 20:25:35 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.11 1998/12/05 15:54:29 curt
// Renamed class fgFLIGHT to class FGState as per request by JSB.
//
#include <GL/glut.h>
#include <XGL/xgl.h>
-#ifdef __BORLANDC__
+#include "Include/compiler.h"
+
+#ifdef FG_MATH_EXCEPTION_CLASH
# define exception c_exception
#endif
-#include <math.h>
-#include <string.h>
+#ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+#else
+# include <math.h>
+#endif
+
+#include <string>
+FG_USING_STD(string);
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
// initialize lighting tables
void fgLIGHT::Init( void ) {
- string path, ambient, diffuse, sky;
-
FG_LOG( FG_EVENT, FG_INFO,
"Initializing Lighting interpolation tables." );
// build the path name to the ambient lookup table
- path = current_options.get_fg_root();
- ambient = path + "/Lighting/ambient";
- diffuse = path + "/Lighting/diffuse";
- sky = path + "/Lighting/sky";
+ string path = current_options.get_fg_root();
+ string ambient = path + "/Lighting/ambient";
+ string diffuse = path + "/Lighting/diffuse";
+ string sky = path + "/Lighting/sky";
// initialize ambient table
- ambient_tbl = new fgINTERPTABLE((char *)ambient.c_str());
+ ambient_tbl = new fgINTERPTABLE( ambient );
// initialize diffuse table
- diffuse_tbl = new fgINTERPTABLE((char *)diffuse.c_str());
+ diffuse_tbl = new fgINTERPTABLE( diffuse );
// initialize sky table
- sky_tbl = new fgINTERPTABLE((char *)sky.c_str());
+ sky_tbl = new fgINTERPTABLE( sky );
}
// $Log$
+// Revision 1.25 1999/01/07 20:25:36 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.24 1998/12/09 18:50:35 curt
// Converted "class fgVIEW" to "class FGView" and updated to make data
// members private and make required accessor functions.
# include <config.h>
#endif
-#include <math.h>
-#include <stdio.h>
-#include <time.h>
+#include "Include/compiler.h"
+#ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# include <cstdio>
+# include <ctime>
+#else
+# include <math.h>
+# include <stdio.h>
+# include <time.h>
+#endif
+
//#include <Astro/orbits.hxx>
#include <Astro/solarsystem.hxx>
// $Log$
+// Revision 1.19 1999/01/07 20:25:37 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.18 1998/12/09 18:50:36 curt
// Converted "class fgVIEW" to "class FGView" and updated to make data
// members private and make required accessor functions.
# error This library requires C++
#endif
-
-#include <time.h>
+#include "Include/compiler.h"
+#ifdef FG_HAVE_STD_INCLUDES
+# include <ctime>
+#else
+# include <time.h>
+#endif
/* update the cur_time_params structure with the current sun position */
void fgUpdateSunPos( void );
# include <windows.h>
#endif
-#include <time.h>
+#include "Include/compiler.h"
+#ifdef FG_HAVE_STD_INCLUDES
+# include <ctime>
+#else
+# include <time.h>
+#endif
#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h> // for ftime() and struct timeb
// $Log$
+// Revision 1.3 1999/01/07 20:25:39 curt
+// Portability changes and updates from Bernie Bright.
+//
// Revision 1.2 1998/12/11 20:26:56 curt
// #include tweaks.
//