MSEventControl.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Stores time-dependant events and executes them at the proper time
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef MSEventControl_h
00020 #define MSEventControl_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <utility>
00033 #include <queue>
00034 #include <vector>
00035 #include <map>
00036 #include <utils/common/SUMOTime.h>
00037 #include <utils/common/UtilExceptions.h>
00038 
00039 
00040 // ===========================================================================
00041 // class declarations
00042 // ===========================================================================
00043 class Command;
00044 
00045 
00046 // ===========================================================================
00047 // class definitions
00048 // ===========================================================================
00053 class MSEventControl {
00054 public:
00056     typedef std::pair< Command*, SUMOTime > Event;
00057 
00058 
00063     enum AdaptType {
00065         ADAPT_AFTER_EXECUTION = 1,
00067         NO_CHANGE = 2
00068     };
00069 
00070 
00071 public:
00073     MSEventControl() throw();
00074 
00075 
00077     virtual ~MSEventControl() throw();
00078 
00079 
00094     virtual SUMOTime addEvent(Command* operation, SUMOTime execTimeStep,
00095                               AdaptType type) throw();
00096 
00097 
00115     virtual void execute(SUMOTime time) throw(ProcessError);
00116 
00117 
00122     bool isEmpty() throw();
00123 
00124 
00131     void setCurrentTimeStep(SUMOTime time);
00132 
00133 
00134 protected:
00139     class EventSortCrit {
00140     public:
00142         bool operator()(const Event& e1, const Event& e2) const {
00143             return e1.second > e2.second;
00144         }
00145     };
00146 
00147 
00148 private:
00150     typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > EventCont;
00151 
00153     SUMOTime currentTimeStep;
00154 
00156     EventCont myEvents;
00157 
00159     SUMOTime getCurrentTimeStep() throw();
00160 
00161 
00162 private:
00164     MSEventControl(const MSEventControl&);
00165 
00167     MSEventControl& operator=(const MSEventControl&);
00168 
00169 
00170 };
00171 
00172 
00173 #endif
00174 
00175 /****************************************************************************/
00176 

Generated on Wed May 5 00:06:31 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6