//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / OVOPS++
//
//File: timer.h
//
//Version: $Revision: 1.21 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/19 08:46:02 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
// 
//Authors:
//      Pasi Nummisalo
//      Timo Pärnänen
//      Juhana Räsänen
//
//Description:
//      Timer class is used to capture timeouts and to produce
//      Timer Messengers.
//      Timer Messengers are used to indicate timeouts to the protocols.
//
//Copyright:     
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//      
//Licence:
//     
//
//History:
//
//
 
#ifndef ___PF_TIMER_H__
#define ___PF_TIMER_H__

class pfProtocol;
class pfTimerMessenger;

#include "pf/types.h"
#include "pf/messenge.h"
#include "sf/task.h"
#include "sf/otime.h"

class pfTimer : public sfTask
{
    public:
        pfTimer(void);
        pfTimer(const pfTimer &other_);
        virtual ~pfTimer(void);

        const pfTimer &operator=(const pfTimer &other_);

        virtual void timeoutCallback(void);
        virtual void setTimeout(pfUlong msec_);
        virtual void setHost(pfProtocol *host_);
        virtual void setMessenger(pfTimerMessenger *timerMessenger_);
        virtual void start(void);
        virtual void stop(void);
        virtual bool isActive(void) const;

    private:
        pfProtocol *_host;
        pfTimerMessenger *_timerMessenger;
        bool _active;
        OTime _timeout;
};

class pfTimerMessenger : public pfMessenger
{
    public:
        virtual void apply(pfState *state_, pfProtocol *protocol_) = 0;
        virtual pfTimerMessenger *clone(void) const = 0;
};

#endif // __PF_TIMER_H__

