SUMO - Simulation of Urban MObility
GUIRunThread.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // The thread that runs the simulation
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef GUIRunThread_h
00023 #define GUIRunThread_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <string>
00036 #include <iostream>
00037 #include <fx.h>
00038 #include <utils/foxtools/FXSingleEventThread.h>
00039 #include <utils/foxtools/FXRealSpinDial.h>
00040 #include <utils/foxtools/FXThreadEvent.h>
00041 #include <utils/foxtools/MFXEventQue.h>
00042 #include <utils/common/SUMOTime.h>
00043 
00044 
00045 // ===========================================================================
00046 // class declarations
00047 // ===========================================================================
00048 class GUINet;
00049 class OutputDevice;
00050 
00051 
00052 // ===========================================================================
00053 // class definition
00054 // ===========================================================================
00062 class GUIRunThread : public FXSingleEventThread {
00063 public:
00065     GUIRunThread(FXApp* app, MFXInterThreadEventClient* mw,
00066                  FXRealSpinDial& simDelay, MFXEventQue& eq, FXEX::FXThreadEvent& ev);
00067 
00069     virtual ~GUIRunThread();
00070 
00072     virtual void init(GUINet* net, SUMOTime start, SUMOTime end);
00073 
00075     virtual FXint run();
00076 
00079     void resume();
00080 
00083     void singleStep();
00084 
00086     virtual void begin();
00087 
00089     void stop();
00090 
00092     bool simulationAvailable() const;
00093 
00094     virtual bool simulationIsStartable() const;
00095     virtual bool simulationIsStopable() const;
00096     virtual bool simulationIsStepable() const;
00097 
00099     virtual void deleteSim();
00100 
00102     GUINet& getNet() const;
00103 
00105     void prepareDestruction();
00106 
00108     void retrieveMessage(const MsgHandler::MsgType type, const std::string& msg);
00109 
00110 protected:
00111     void makeStep() ;
00112 
00113 protected:
00115     GUINet* myNet;
00116 
00118     SUMOTime mySimStartTime, mySimEndTime;
00119 
00121     bool myHalting;
00122 
00125     bool myQuit;
00126 
00130     bool mySimulationInProgress;
00131 
00132     bool myOk;
00133 
00135     bool mySingle;
00136 
00139     OutputDevice* myErrorRetriever, *myMessageRetriever, *myWarningRetriever;
00140 
00141     FXRealSpinDial& mySimDelay;
00142 
00143     MFXEventQue& myEventQue;
00144 
00145     FXEX::FXThreadEvent& myEventThrow;
00146 
00147     MFXMutex mySimulationLock;
00148 
00149 };
00150 
00151 
00152 #endif
00153 
00154 /****************************************************************************/
00155 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines