SUMO - Simulation of Urban MObility

MSDetectorControl.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Detectors container; responsible for string and output generation
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 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 MSDetectorControl_h
00020 #define MSDetectorControl_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 <string>
00033 #include <vector>
00034 #include <utils/common/NamedObjectCont.h>
00035 #include <utils/xml/SUMOXMLDefinitions.h>
00036 #include <microsim/output/MSE2Collector.h>
00037 #include <microsim/output/MS_E2_ZS_CollectorOverLanes.h>
00038 #include <microsim/output/MSE3Collector.h>
00039 #include <microsim/output/MSInductLoop.h>
00040 #include <microsim/output/MSRouteProbe.h>
00041 
00042 #ifdef HAVE_MESOSIM
00043 #include <mesosim/MEInductLoop.h>
00044 #endif
00045 
00046 
00047 // ===========================================================================
00048 // class declarations
00049 // ===========================================================================
00050 class MSMeanData;
00051 
00052 
00053 // ===========================================================================
00054 // class definitions
00055 // ===========================================================================
00060 class MSDetectorControl {
00061 public:
00062     // well, well, friends are evil; one could think about overriding MSDetectorControl and introducing GUIDetectorControl...
00063     friend class GUINet;
00064 
00065 
00068     MSDetectorControl() throw();
00069 
00070 
00075     ~MSDetectorControl() throw();
00076 
00077 
00085     void close(SUMOTime step);
00086 
00087 
00104     void add(SumoXMLTag type, MSDetectorFileOutput* d, OutputDevice& device, int splInterval, SUMOTime begin=-1) throw(ProcessError);
00105 
00106 
00107 
00120     void add(SumoXMLTag type, MSDetectorFileOutput* d) throw(ProcessError);
00121 
00122 
00134     void add(MSMeanData* mn, OutputDevice& device,
00135              SUMOTime frequency, SUMOTime begin) throw();
00136 
00137 
00138 
00146     void addDetectorAndInterval(MSDetectorFileOutput* det,
00147                                 OutputDevice* device,
00148                                 SUMOTime interval, SUMOTime begin=-1) throw();
00149 
00150 
00151 
00157     const NamedObjectCont<MSDetectorFileOutput*> &getTypedDetectors(SumoXMLTag type) const throw();
00158 
00159 
00160 
00169     void updateDetectors(const SUMOTime step) throw();
00170 
00171 
00183     void writeOutput(SUMOTime step, bool closing) throw(IOError);
00184 
00185 
00186 protected:
00189 
00191     typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
00192 
00194     typedef std::vector< DetectorFilePair > DetectorFileVec;
00195 
00197     typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
00198 
00200     typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
00202 
00214     struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
00216         bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const throw() {
00217             return pair.first == det;
00218         }
00219     };
00220 
00221 protected:
00223     std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
00224 
00225 
00227     Intervals myIntervals;
00228 
00230     std::map<IntervalsKey, SUMOTime> myLastCalls;
00231 
00233     std::vector<MSMeanData*> myMeanData;
00234 
00236     NamedObjectCont< MSDetectorFileOutput*> myEmptyContainer;
00237 
00238 
00239 private:
00241     MSDetectorControl(const MSDetectorControl&);
00242 
00244     MSDetectorControl& operator=(const MSDetectorControl&);
00245 
00246 
00247 };
00248 
00249 
00250 #endif
00251 
00252 /****************************************************************************/
00253 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines