SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDetectorControl.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // Detectors container; responsible for string and output generation
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSDetectorControl_h
25 #define MSDetectorControl_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <vector>
46 
47 #ifdef HAVE_INTERNAL
48 #include <mesosim/MEInductLoop.h>
49 #endif
50 
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 class MSMeanData;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
66 public:
67  // well, well, friends are evil; one could think about overriding MSDetectorControl and introducing GUIDetectorControl...
68  friend class GUINet;
69 
70 
74 
75 
81 
82 
90  void close(SUMOTime step);
91 
92 
109  void add(SumoXMLTag type, MSDetectorFileOutput* d, OutputDevice& device, int splInterval, SUMOTime begin = -1);
110 
111 
112 
125  void add(SumoXMLTag type, MSDetectorFileOutput* d);
126 
127 
139  void add(MSMeanData* mn, OutputDevice& device,
140  SUMOTime frequency, SUMOTime begin);
141 
142 
143 
152  OutputDevice* device,
153  SUMOTime interval, SUMOTime begin = -1);
154 
155 
156 
163 
164 
165 
174  void updateDetectors(const SUMOTime step);
175 
176 
188  void writeOutput(SUMOTime step, bool closing);
189 
190 
191 protected:
194 
196  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
197 
199  typedef std::vector< DetectorFilePair > DetectorFileVec;
200 
202  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
203 
205  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
207 
219  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
221  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
222  return pair.first == det;
223  }
224  };
225 
226 protected:
228  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
229 
230 
233 
235  std::map<IntervalsKey, SUMOTime> myLastCalls;
236 
238  std::vector<MSMeanData*> myMeanData;
239 
242 
243 
244 private:
247 
250 
251 
252 };
253 
254 
255 #endif
256 
257 /****************************************************************************/
258