SUMO - Simulation of Urban MObility
MSDetectorControl.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
21 // Detectors container; responsible for string and output generation
22 /****************************************************************************/
23 #ifndef MSDetectorControl_h
24 #define MSDetectorControl_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class MSMeanData;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
60 public:
64 
65 
71 
72 
80  void close(SUMOTime step);
81 
82 
99  void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime splInterval, SUMOTime begin = -1);
100 
101 
102 
115  void add(SumoXMLTag type, MSDetectorFileOutput* d);
116 
117 
129  void add(MSMeanData* mn, const std::string& device,
130  SUMOTime frequency, SUMOTime begin);
131 
132 
133 
142  OutputDevice* device,
143  SUMOTime interval, SUMOTime begin = -1);
144 
145 
146 
151  const std::vector<SumoXMLTag> getAvailableTypes() const;
152 
153 
160 
161 
170  void updateDetectors(const SUMOTime step);
171 
172 
184  void writeOutput(SUMOTime step, bool closing);
185 
186 
187 protected:
190 
192  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
193 
195  typedef std::vector< DetectorFilePair > DetectorFileVec;
196 
198  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
199 
201  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
203 
215  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
217  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
218  return pair.first == det;
219  }
220  };
221 
222 protected:
224  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
225 
226 
228  Intervals myIntervals;
229 
231  std::map<IntervalsKey, SUMOTime> myLastCalls;
232 
234  std::vector<MSMeanData*> myMeanData;
235 
238 
239 
240 private:
243 
246 
247 
248 };
249 
250 
251 #endif
252 
253 /****************************************************************************/
254 
std::vector< DetectorFilePair > DetectorFileVec
Container holding DetectorFilePair (with the same interval).
std::pair< MSDetectorFileOutput *, OutputDevice *> DetectorFilePair
A pair of a Detector with it&#39;s associated file-stream.
Data collector for edges/lanes.
Definition: MSMeanData.h:66
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::vector< MSMeanData * > myMeanData
List of harmonoise detectors.
std::map< IntervalsKey, SUMOTime > myLastCalls
The map that holds the last call for each sample interval.
void updateDetectors(const SUMOTime step)
Computes detector values.
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
A map of named object pointers.
Detectors container; responsible for string and output generation.
Returns true if detectors are equal.
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
An empty container to return in getTypedDetectors() if no detectors of the asked type exist...
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
bool operator()(const DetectorFilePair &pair, const MSDetectorFileOutput *det) const
Returns true if detectors are equal.
MSDetectorControl & operator=(const MSDetectorControl &)
Invalidated assignment operator.
std::map< IntervalsKey, DetectorFileVec > Intervals
Association of intervals to DetectorFilePair containers.
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key.
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
The detectors map, first by detector type, then using NamedObjectCont (.
void close(SUMOTime step)
Closes the detector outputs.
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
~MSDetectorControl()
Destructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
MSDetectorControl()
Constructor.
Intervals myIntervals
Map that hold DetectorFileVec for given intervals.
void addDetectorAndInterval(MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1)
Adds one of the detectors as a new MSDetectorFileOutput.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
Base of value-generating classes (detectors)