Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

EventBaseSched.h

00001 //   -*- C++ -*-
00002 /*****************************************************************************
00003  *
00004  *   |_|_|_  |_|_    |_    |_|_|_  |_                C O M M U N I C A T I O N
00005  * |_        |_  |_  |_  |_        |_                          N E T W O R K S
00006  * |_        |_  |_  |_  |_        |_                                C L A S S
00007  *   |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                      L I B R A R Y
00008  *
00009 
00010  *
00011  * Class: CNEventBaseSched --- Abstract scheduler base class
00012  *
00013  *****************************************************************************
00014  * Copyright (C) 1992-2002   Communication Networks
00015  *                           Aachen University of Technology
00016  *                           D-52056 Aachen
00017  *                           Germany
00018  *                           Email: cncl-adm@comnets.rwth-aachen.de
00019  *****************************************************************************
00020  * This file is part of the CN class library. All files marked with
00021  * this header are free software; you can redistribute it and/or modify
00022  * it under the terms of the GNU Library General Public License as
00023  * published by the Free Software Foundation; either version 2 of the
00024  * License, or (at your option) any later version.  This library is
00025  * distributed in the hope that it will be useful, but WITHOUT ANY
00026  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00027  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00028  * License for more details.  You should have received a copy of the GNU
00029  * Library General Public License along with this library; if not, write
00030  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
00031  * USA.
00032  *****************************************************************************/
00033 
00034 #ifndef __CNEventBaseSched_h
00035 #define __CNEventBaseSched_h
00036 #include <CNCL/Object.h>                // Base class
00037 #include <CNCL/Event.h>
00038 #include <CNCL/EventHandler.h>
00039 #include <CNCL/Statistics.h>
00040 
00041 
00042 extern CNClassDesc CN_EVENTBASESCHED;   // Class CNEventBaseSched description
00043 
00044 class CNEventIterator;
00045 
00046 
00050 class CNEventBaseSched : public CNObject
00051 {
00052   public:       /****** Constructors ******************************************/
00054         CNEventBaseSched()          : simtime(0), stop_flag(FALSE), stat(NIL) {}
00056     CNEventBaseSched(CNParam *) : simtime(0), stop_flag(FALSE), stat(NIL) {}
00057 
00058   public:       /****** Public interface **************************************/
00060     virtual void send_event(CNEvent *ev) = 0;
00062     virtual void add_event(CNEvent *ev) = 0;    
00066     virtual void delete_event(CNEventID id, bool with_obj=FALSE) = 0;
00067 
00070     virtual void delete_events(CNEventHandler*, bool to=TRUE, 
00071                                                            bool with_obj = FALSE) = 0;
00074     void delete_events_from(CNEventHandler *h, bool with_obj = FALSE);  
00077     void delete_events_to(CNEventHandler *h, bool with_obj = FALSE);
00078     
00081     virtual CNEvent *peek_event() = 0;                  
00084     virtual CNEvent *peek_event(CNEventID id) = 0;
00086     virtual CNEvent *next_event() = 0;
00087     
00089     virtual void start();
00091     virtual void start(CNEvent *ev);
00092 
00096     virtual void stop(bool with_obj = FALSE) = 0;
00098     virtual bool stopped() {return stop_flag;}
00099 
00102         virtual void reset(bool with_obj = FALSE);               
00103 
00105     virtual CNEventIterator *create_iterator() = 0; 
00107     CNSimTime time() { return simtime; }                
00108 
00110         CNStatistics *statistics() const           { return stat; };
00112         void statistics(CNStatistics *st) { stat = st;   };
00113     
00115     virtual void process_event();       
00117     virtual void process_events();      
00119     virtual void process_now();         
00120                 
00121 
00122   protected:    /****** Protected stuff for event handler implementation ******/
00124     CNSimTime simtime;  
00126     bool stop_flag;
00128     CNStatistics *stat; 
00129     
00130 
00131   public:       /****** Member functions required by CNCL *********************/
00132     virtual CNClassDesc class_desc() const      // CNClass description
00133     { return CN_EVENTBASESCHED; }
00134             
00136     virtual bool is_a(CNClassDesc desc) const
00137     { return desc == CN_EVENTBASESCHED ? TRUE : CNObject::is_a(desc); }
00138         
00140     static CNEventBaseSched *cast_from_object(CNObject *obj)
00141     {
00142 #   ifdef NO_TYPE_CHECK
00143         return (CNEventBaseSched *)obj;
00144 #   else
00145         return (CNEventBaseSched *)( !obj || obj->is_a(CN_EVENTBASESCHED)
00146                ? obj : fatal_type(obj->class_desc(), CN_EVENTBASESCHED) );
00147 #   endif
00148     }
00149     
00151     virtual void print(ostream &strm = cout) const = 0;
00153     virtual void dump (ostream &strm = cout) const = 0;
00154 };
00155 
00156 #endif 
00158 // {{{ Emacs Local Variables
00159 
00160 /*
00161  * Local Variables:
00162  * mode: c++
00163  * folded-file: t
00164  * tab-width:4
00165  * comment-column:40
00166  * End:
00167  */
00168 
00169 // }}}

Generated on Fri Feb 1 19:53:48 2002 for CNCL by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001