SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSDetectorFileOutput.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Base of value-generating classes (detectors)
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSDetectorFileOutput_h
24 #define MSDetectorFileOutput_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 <set>
38 
39 #include <utils/common/Named.h>
40 #include <utils/common/SUMOTime.h>
44 #include <microsim/MSVehicleType.h>
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class GUIDetectorWrapper;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
60 };
61 
69 class MSDetectorFileOutput : public Named {
70 public:
72  MSDetectorFileOutput(const std::string& id, const std::string& vTypes)
73  : Named(id) {
74  const std::vector<std::string> vt = StringTokenizer(vTypes).getVector();
75  myVehicleTypes.insert(vt.begin(), vt.end());
76  }
77 
79  MSDetectorFileOutput(const std::string& id, const std::set<std::string>& vTypes)
80  : Named(id), myVehicleTypes(vTypes) {
81  }
82 
83 
85  virtual ~MSDetectorFileOutput() { }
86 
87 
90 
97  virtual void writeXMLOutput(OutputDevice& dev,
98  SUMOTime startTime, SUMOTime stopTime) = 0;
99 
100 
109  virtual void writeXMLDetectorProlog(OutputDevice& dev) const = 0;
110 
111 
119  virtual void reset() { }
120 
121 
126  virtual void detectorUpdate(const SUMOTime step) {
127  UNUSED_PARAMETER(step);
128  }
129 
130 
137  return 0;
138  }
139 
140 
146  bool vehicleApplies(const SUMOVehicle& veh) const {
147  return myVehicleTypes.empty() || myVehicleTypes.count(veh.getVehicleType().getID()) > 0;
148  }
149 
150 
155  bool isTyped() const {
156  return !myVehicleTypes.empty();
157  }
158 
159 
160 protected:
162  std::set<std::string> myVehicleTypes;
163 
164 private:
167 
170 
171 
172 };
173 
174 
175 #endif
176 
177 /****************************************************************************/
178 
long long int SUMOTime
Definition: SUMOTime.h:43
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
virtual void reset()
Resets collected values.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
virtual void detectorUpdate(const SUMOTime step)
Updates the detector (computes values)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const =0
Open the XML-output.
MSDetectorFileOutput(const std::string &id, const std::string &vTypes)
Constructor.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
MSDetectorFileOutput & operator=(const MSDetectorFileOutput &)
Invalidated assignment operator.
bool isTyped() const
Checks whether the detector is type specific.
virtual ~MSDetectorFileOutput()
(virtual) destructor
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
MSDetectorFileOutput(const std::string &id, const std::set< std::string > &vTypes)
Constructor.
Base class for objects which have an id.
Definition: Named.h:46
std::vector< std::string > getVector()
const std::string & getID() const
Returns the name of the vehicle type.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Builds the graphical representation.
Base of value-generating classes (detectors)
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.