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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
19 // Detectors container; responsible for string and output generation
20 /****************************************************************************/
21 #ifndef MSDetectorControl_h
22 #define MSDetectorControl_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <string>
31 #include <vector>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSMeanData;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 public:
58 
59 
65 
66 
74  void close(SUMOTime step);
75 
76 
93  void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime splInterval, SUMOTime begin = -1);
94 
95 
96 
109  void add(SumoXMLTag type, MSDetectorFileOutput* d);
110 
111 
123  void add(MSMeanData* mn, const std::string& device,
124  SUMOTime frequency, SUMOTime begin);
125 
126 
127 
136  OutputDevice* device,
137  SUMOTime interval, SUMOTime begin = -1);
138 
139 
140 
145  const std::vector<SumoXMLTag> getAvailableTypes() const;
146 
147 
154 
155 
164  void updateDetectors(const SUMOTime step);
165 
166 
178  void writeOutput(SUMOTime step, bool closing);
179 
180 
181 protected:
184 
186  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
187 
189  typedef std::vector< DetectorFilePair > DetectorFileVec;
190 
192  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
193 
195  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
197 
209  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
211  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
212  return pair.first == det;
213  }
214  };
215 
216 protected:
218  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
219 
220 
222  Intervals myIntervals;
223 
225  std::map<IntervalsKey, SUMOTime> myLastCalls;
226 
228  std::vector<MSMeanData*> myMeanData;
229 
232 
233 
234 private:
237 
240 
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248 
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:60
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::vector< MSMeanData * > myMeanData
List of harmonoise detectors.
long long int SUMOTime
Definition: SUMOTime.h:36
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:64
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)