diff options
Diffstat (limited to 'comm/TimeOut.h')
-rw-r--r-- | comm/TimeOut.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/comm/TimeOut.h b/comm/TimeOut.h index 8364713..070e8af 100644 --- a/comm/TimeOut.h +++ b/comm/TimeOut.h @@ -39,6 +39,32 @@ protected: public: UchTimeOut (UchBaseMultiplexer&, Millisecond, void (*) (Millisecond), int = -1); ~UchTimeOut (); +inline void SetHandler (void (*h) (Millisecond)) { Handler = h; } }; -#endif /* UchBaseOut_H_ */ +#define SpecializedTimeOut(R,S) \ +class R : public UchBaseTimeOut { \ +protected: \ + S& Object; \ + void (S::*Handler) (Millisecond); \ +public: \ + R (UchBaseMultiplexer& m, Millisecond t, S& s, void (S::*sc) (Millisecond), int nb = -1) : UchBaseTimeOut (m, t, nb), Object (s), Handler (sc) {} \ + ~R () {} \ + void Handle (Millisecond t) { (Object.*Handler) (t); } \ +inline void SetHandler (void (S::*h) (Millisecond)) { Handler = h; } \ +}; + +template <class T> class UchTimeOutFor : public UchBaseTimeOut { +protected: + T& Object; + void (T::*Handler) (Millisecond); + + void Handle (Millisecond ref) { (Object.*Handler) (ref); } + +public: + UchTimeOutFor (UchBaseMultiplexer& m, Millisecond t, T& o, void (T::*h) (Millisecond), int nb = -1) : UchBaseTimeOut (m, t, nb), Object (o), Handler (h) {} + ~UchTimeOutFor () {} +inline void SetHandler (void(T::*h)(Millisecond)) { Handler = h; } +}; + +#endif /* UchTimeOut_H_ */ |