//Editor-Info: -*- C++ -*-
//
//Subject: Scheduler Framework
//
//File: schedulerhandle.h
//
//Version: $Revision: 1.5 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/06 08:00:20 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Juhana Räsänen
//
//Description:
//      A base class for scheduler handles that provide the tasks
//      an interface to the scheduler.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 


#ifndef __SF_SCHEDULERHANDLE_H__
#define __SF_SCHEDULERHANDLE_H__

class sfTask;
class sfScheduler;
class OTime;

#include <typeinfo>

//
// Class: sfSchedulerHandle
//
// Description:
//     Scheduler handle base class. Accepts three kind of requests from
//     host tasks: i) execution ii) timeouts iii) asynchronous I/O. The
//     requests can be cancelled with unschedule-methods, or a task can be
//     removed from all scheduler queues by calling removeTask() method
//     (practical in task destructor, where it *must* be ensured that no
//     deleted tasks remain in the scheduler queues).
//     Scheduler handles act according to Bridge pattern and separate
//     the implementation of a scheduler from its interface. Concrete
//     handle classes should be defined within concrete schedulers.
//     See sfFIFOScheduler implementation as an example.
//

class sfSchedulerHandle
{
    public:
        explicit sfSchedulerHandle(sfTask *task_);
        virtual ~sfSchedulerHandle(void);

        virtual void scheduleTask(void) = 0;
        virtual void scheduleTimeout(const OTime &timeout_) = 0;
        virtual void scheduleAbsoluteTimeout(const OTime &timeout_) = 0;
        virtual void scheduleRead(int fileDescriptor_,
                                  const OTime &timeout_) = 0;
        virtual void scheduleWrite(int fileDescriptor_,
                                   const OTime &timeout_) = 0;

        virtual void removeTask(void) = 0;
        virtual void unscheduleTask(void) = 0;
        virtual void unscheduleTimeout(void) = 0;
        virtual void unscheduleRead(void) = 0;
        virtual void unscheduleWrite(void) = 0;

    protected:
        sfTask *_task;
};

#endif // __SF_SCHEDULERHANDLE_H__

