From b896b2810287f6e0f7c09c837930e2da823e47aa Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 8 Feb 1995 14:43:51 +0000 Subject: Added UchTimeOutFor and SetHandler --- comm/TimeOut.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'comm/TimeOut.h') 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 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_ */ -- cgit v1.1