using namespace icinga;
+namespace icinga {
+
+class TimerHolder {
+public:
+ TimerHolder(Timer *timer)
+ : m_Timer(timer)
+ { }
+
+ inline Timer *GetObject(void) const
+ {
+ return m_Timer;
+ }
+
+ inline double GetNextUnlocked(void) const
+ {
+ return m_Timer->m_Next;
+ }
+
+ operator Timer *(void) const
+ {
+ return m_Timer;
+ }
+
+private:
+ Timer *m_Timer;
+};
+
+}
+
typedef boost::multi_index_container<
- Timer::Holder,
+ TimerHolder,
boost::multi_index::indexed_by<
- boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<Timer::Holder, Timer *, &Timer::Holder::GetObject> >,
- boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<Timer::Holder, double, &Timer::Holder::GetNextUnlocked> >
+ boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<TimerHolder, Timer *, &TimerHolder::GetObject> >,
+ boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<TimerHolder, double, &TimerHolder::GetNextUnlocked> >
>
> TimerSet;
namespace icinga {
+class TimerHolder;
+
/**
* A timer that periodically triggers an event.
*
boost::signals2::signal<void(const Timer::Ptr&)> OnTimerExpired;
- class Holder {
- public:
- Holder(Timer *timer)
- : m_Timer(timer)
- { }
-
- inline Timer *GetObject(void) const
- {
- return m_Timer;
- }
-
- inline double GetNextUnlocked(void) const
- {
- return m_Timer->m_Next;
- }
-
- operator Timer *(void) const
- {
- return m_Timer;
- }
-
- private:
- Timer *m_Timer;
- };
-
private:
double m_Interval; /**< The interval of the timer. */
double m_Next; /**< When the next event should happen. */
static void Uninitialize(void);
friend class Application;
+ friend class TimerHolder;
};
}