]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/event_mgr.hxx
Some Linux platforms need <cstdio> for snprintf.
[simgear.git] / simgear / structure / event_mgr.hxx
index 5b31c8095bf168b8853f7bb6fe7b6607e917a4ff..699522b8082ef5ba3d5c3c9743ed15b0cfd68a03 100644 (file)
@@ -8,14 +8,16 @@
 
 class SGEventMgr;
 
-struct SGTimer {
+class SGTimer {
+public:
+    ~SGTimer();
+    void run();
+    
     std::string name;
     double interval;
     SGCallback* callback;
-    SGEventMgr* mgr;
     bool repeat;
-    bool simtime;
-    void run();
+    bool running;
 };
 
 class SGTimerQueue {
@@ -23,6 +25,7 @@ public:
     SGTimerQueue(int preSize=1);
     ~SGTimerQueue();
 
+    void clear();
     void update(double deltaSecs);
 
     double now() { return _now; }
@@ -37,7 +40,7 @@ public:
     SGTimer* findByName(const std::string& name) const;
 private:
     // The "priority" is stored as a negative time.  This allows the
-    // implemenetation to treat the "top" of the heap as the largest
+    // implementation to treat the "top" of the heap as the largest
     // value and avoids developer mindbugs. ;)
     struct HeapEntry { double pri; SGTimer* timer; };
 
@@ -66,12 +69,14 @@ private:
 class SGEventMgr : public SGSubsystem
 {
 public:
-    SGEventMgr() { _rtProp = 0; }
-    ~SGEventMgr() { _rtProp = 0; }
+    SGEventMgr();
+    ~SGEventMgr();
 
-    virtual void init() {}
+    virtual void init();
     virtual void update(double delta_time_sec);
-
+    virtual void unbind();
+    virtual void shutdown();
+    
     void setRealtimeProperty(SGPropertyNode* node) { _rtProp = node; }
 
     /**
@@ -115,7 +120,7 @@ public:
 
     void removeTask(const std::string& name);
 private:
-    friend struct SGTimer;
+    friend class SGTimer;
 
     void add(const std::string& name, SGCallback* cb,
              double interval, double delay,
@@ -125,6 +130,7 @@ private:
     SGPropertyNode_ptr _rtProp;
     SGTimerQueue _rtQueue; 
     SGTimerQueue _simQueue;
+    bool _inited;
 };
 
 #endif // _SG_EVENT_MGR_HXX