]> Dogcows Code - chaz/openbox/blobdiff - src/timer.hh
new timers, timer manager
[chaz/openbox] / src / timer.hh
index 121dfbc9f6bd62432c52f9f1106bd0036eae0f49..774d0e49c385743e0ae476ddfccd5cf1da4bbb53 100644 (file)
@@ -22,27 +22,26 @@ extern "C" {
 namespace ob {
 
 // forward declaration
-class TimerQueueManager;
+class OBTimerQueueManager;
 
 class TimeoutHandler {
 public:
   virtual void timeout(void) = 0;
 };
 
-class BTimer {
+class OBTimer {
 private:
-  TimerQueueManager *manager;
   TimeoutHandler *handler;
   bool timing, recur;
 
   timeval _start, _timeout;
 
-  BTimer(const BTimer&);
-  BTimer& operator=(const BTimer&);
+  OBTimer(const OBTimer&);
+  OBTimer& operator=(const OBTimer&);
 
 public:
-  BTimer(TimerQueueManager *m, TimeoutHandler *h);
-  virtual ~BTimer(void);
+  OBTimer(TimeoutHandler *h);
+  virtual ~OBTimer(void);
 
   void fireTimeout(void);
 
@@ -65,7 +64,7 @@ public:
   void stop(void);   // manager releases timer
   void halt(void);   // halts the timer
 
-  bool operator<(const BTimer& other) const
+  bool operator<(const OBTimer& other) const
   { return shouldFire(other.endpoint()); }
 };
 
@@ -95,17 +94,29 @@ private:
 };
 
 struct TimerLessThan {
-  bool operator()(const BTimer* const l, const BTimer* const r) const {
+  bool operator()(const OBTimer* const l, const OBTimer* const r) const {
     return *r < *l;
   }
 };
 
-typedef _timer_queue<BTimer*, std::vector<BTimer*>, TimerLessThan> TimerQueue;
+typedef _timer_queue<OBTimer*,
+                     std::vector<OBTimer*>, TimerLessThan> TimerQueue;
 
-class TimerQueueManager {
+class OBTimerQueueManager {
+private:
+  TimerQueue timerList;
 public:
-  virtual void addTimer(BTimer* timer) = 0;
-  virtual void removeTimer(BTimer* timer) = 0;
+  OBTimerQueueManager() {}
+  virtual ~OBTimerQueueManager() {}
+
+  //! Will wait for and fire the next timer in the queue.
+  /*!
+    The function will stop waiting if an event is received from the X server.
+  */
+  virtual void fire();
+  
+  virtual void addTimer(OBTimer* timer);
+  virtual void removeTimer(OBTimer* timer);
 };
 
 }
This page took 0.021407 seconds and 4 git commands to generate.