/* * The Unix Channel * * by Michel Beaudouin-Lafon and Stephane Chatty * * Copyright 1990-1993 * Laboratoire de Recherche en Informatique (LRI) * Centre d'Etudes de la Navigation Aerienne * * Multiplexer-based timers * * $Id$ * $CurLog$ */ #ifndef UchTimeOut_H_ #define UchTimeOut_H_ #include "ccu/Timer.h" class UchBaseTimeOut : public CcuCoreTimer { friend class UchBaseMultiplexer; protected: UchBaseMultiplexer& MyMpx; void SetAlarm (Millisecond); void StopAlarm (); public: UchBaseTimeOut (UchBaseMultiplexer&, Millisecond, int = -1); ~UchBaseTimeOut (); }; class UchTimeOut : public UchBaseTimeOut { protected: void (*Handler) (Millisecond); void Handle (Millisecond); public: UchTimeOut (UchBaseMultiplexer&, Millisecond, void (*) (Millisecond), int = -1); ~UchTimeOut (); inline void SetHandler (void (*h) (Millisecond)) { Handler = 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_ */