# cscheduler.h

    00001 //=========================================================================
    00002 //  CSCHEDULER.H - part of
    00003 //
    00004 //                  OMNeT++/OMNEST
    00005 //           Discrete System Simulation in C++
    00006 //
    00007 //   Written by:  Andras Varga, 2003
    00008 //
    00009 //=========================================================================
    00010
    00011 /*--------------------------------------------------------------*
    00012   Copyright (C) 2003-2005 Andras Varga
    00013   Monash University, Dept. of Electrical and Computer Systems Eng.
    00014   Melbourne, Australia
    00015
    00016   This file is distributed WITHOUT ANY WARRANTY. See the file
    00017   `license' for details on this and other legal matters.
    00018 *--------------------------------------------------------------*/
    00019
    00020 #ifndef __CSCHEDULER_H
    00021 #define __CSCHEDULER_H
    00022
    00023 #include "cpolymorphic.h"
    00024 #include "platdep/time.h"  // for timeval
    00025
    00026 // forward declarations
    00027 class cSimulation;
    00028 class cMessage;
    00029
    00049 class SIM_API cScheduler : public cPolymorphic
    00050 {
    00051   protected:
    00052     cSimulation *sim;
    00053
    00054   public:
    00058     cScheduler();
    00059
    00063     virtual ~cScheduler();
    00064
    00068     virtual void setSimulation(cSimulation *_sim);
    00069
    00073     virtual void startRun() = 0;
    00074
    00078     virtual void endRun() = 0;
    00079
    00086     virtual void executionResumed()  {}
    00087
    00101     virtual cMessage *getNextEvent() = 0;
    00102 };
    00103
    00109 class SIM_API cSequentialScheduler : public cScheduler
    00110 {
    00111   public:
    00115     cSequentialScheduler() {}
    00116
    00120     virtual void startRun() {}
    00121
    00125     virtual void endRun() {}
    00126
    00131     virtual cMessage *getNextEvent();
    00132 };
    00133
    00134
    00153 class SIM_API cRealTimeScheduler : public cScheduler
    00154 {
    00155   protected:
    00156     // configuration:
    00157     bool doScaling;
    00158     double factor;
    00159
    00160     // state:
    00161     timeval baseTime;
    00162
    00163     bool waitUntil(const timeval& targetTime);
    00164
    00165   public:
    00169     cRealTimeScheduler() : cScheduler()  {}
    00170
    00174     virtual ~cRealTimeScheduler() {}
    00175
    00179     virtual void startRun();
    00180
    00184     virtual void endRun();
    00185
    00189     virtual void executionResumed();
    00190
    00196     virtual cMessage *getNextEvent();
    00197 };
    00198
    00199 #endif
    00200