00001 //========================================================================= 00002 // CSCHEDULER.H - part of 00003 // 00004 // OMNeT++/OMNEST 00005 // Discrete System Simulation in C++ 00006 // 00007 // Author: Andras Varga, 2003 00008 // Dept. of Electrical and Computer Systems Engineering, 00009 // Monash University, Melbourne, Australia 00010 // 00011 //========================================================================= 00012 00013 /*--------------------------------------------------------------* 00014 Copyright (C) 2003-2008 Andras Varga 00015 Copyright (C) 2006-2008 OpenSim Ltd. 00016 00017 This file is distributed WITHOUT ANY WARRANTY. See the file 00018 `license' for details on this and other legal matters. 00019 *--------------------------------------------------------------*/ 00020 00021 #ifndef __CSCHEDULER_H 00022 #define __CSCHEDULER_H 00023 00024 #include "cobject.h" 00025 #include "platdep/timeutil.h" // for timeval 00026 00027 NAMESPACE_BEGIN 00028 00029 // forward declarations 00030 class cSimulation; 00031 class cMessage; 00032 00052 class SIM_API cScheduler : public cObject 00053 { 00054 protected: 00055 cSimulation *sim; 00056 00057 public: 00061 cScheduler(); 00062 00066 virtual ~cScheduler(); 00067 00071 virtual void setSimulation(cSimulation *_sim); 00072 00076 virtual void startRun() = 0; 00077 00081 virtual void endRun() = 0; 00082 00089 virtual void executionResumed() {} 00090 00104 virtual cMessage *getNextEvent() = 0; 00105 }; 00106 00112 class SIM_API cSequentialScheduler : public cScheduler 00113 { 00114 public: 00118 cSequentialScheduler() {} 00119 00123 virtual void startRun() {} 00124 00128 virtual void endRun() {} 00129 00134 virtual cMessage *getNextEvent(); 00135 }; 00136 00137 00156 class SIM_API cRealTimeScheduler : public cScheduler 00157 { 00158 protected: 00159 // configuration: 00160 bool doScaling; 00161 double factor; 00162 00163 // state: 00164 timeval baseTime; 00165 00166 bool waitUntil(const timeval& targetTime); 00167 00168 public: 00172 cRealTimeScheduler() : cScheduler() {} 00173 00177 virtual ~cRealTimeScheduler() {} 00178 00182 virtual void startRun(); 00183 00187 virtual void endRun(); 00188 00192 virtual void executionResumed(); 00193 00199 virtual cMessage *getNextEvent(); 00200 }; 00201 00202 NAMESPACE_END 00203 00204 00205 #endif 00206