Eclipse SUMO - Simulation of Urban MObility
MSDetectorFileOutput.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // Base of value-generating classes (detectors)
23 /****************************************************************************/
24 #pragma once
25 #include <config.h>
26 
27 #include <string>
28 #include <set>
29 
30 #include <utils/common/Named.h>
32 #include <utils/common/SUMOTime.h>
33 #include <microsim/MSNet.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class OutputDevice;
40 class GUIDetectorWrapper;
41 class SUMOTrafficObject;
42 class MSTransportable;
43 class MSEdge;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
53 };
54 
62 class MSDetectorFileOutput : public Named, public Parameterised {
63 public:
65  MSDetectorFileOutput(const std::string& id, const std::string& vTypes, const std::string& nextEdges = "", const int detectPersons = false);
66 
68  virtual ~MSDetectorFileOutput() { }
69 
70 
73 
80  virtual void writeXMLOutput(OutputDevice& dev,
81  SUMOTime startTime, SUMOTime stopTime) = 0;
82 
83 
92  virtual void writeXMLDetectorProlog(OutputDevice& dev) const = 0;
93 
94 
102  virtual void reset() { }
103 
104 
109  virtual void detectorUpdate(const SUMOTime step) {
110  UNUSED_PARAMETER(step);
111  }
112 
113 
120  return 0;
121  }
122 
123 
129  bool vehicleApplies(const SUMOTrafficObject& veh) const;
130 
131  bool personApplies(const MSTransportable& p, int dir) const;
132 
133 
138  bool isTyped() const {
139  return !myVehicleTypes.empty();
140  }
141 
142  const std::set<std::string>& getVehicleTypes() const {
143  return myVehicleTypes;
144  }
145 
146  inline bool detectPersons() const {
147  return myDetectPersons != 0;
148  }
149 
151  virtual void clearState(SUMOTime /*step*/) {};
152 
153 protected:
155  std::set<std::string> myVehicleTypes;
156 
158  std::vector<const MSEdge*> myNextEdges;
159 
161  const int myDetectPersons;
162 
163 private:
166 
169 
170 
171 };
long long int SUMOTime
Definition: GUI.h:35
@ DU_USER_DEFINED
@ DU_SUMO_INTERNAL
@ DU_TL_CONTROL
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
Base of value-generating classes (detectors)
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Builds the graphical representation.
virtual void clearState(SUMOTime)
Remove all vehicles before quick-loading state.
bool isTyped() const
Checks whether the detector is type specific.
MSDetectorFileOutput(const MSDetectorFileOutput &)
Invalidated copy constructor.
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
std::vector< const MSEdge * > myNextEdges
The upcoming edges to filter by (empty means no filtering)
const int myDetectPersons
Whether pedestrians shall be detected instead of vehicles.
MSDetectorFileOutput(const std::string &id, const std::string &vTypes, const std::string &nextEdges="", const int detectPersons=false)
Constructor.
virtual void reset()
Resets collected values.
virtual void detectorUpdate(const SUMOTime step)
Updates the detector (computes values)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const =0
Open the XML-output.
const std::set< std::string > & getVehicleTypes() const
MSDetectorFileOutput & operator=(const MSDetectorFileOutput &)
Invalidated assignment operator.
virtual ~MSDetectorFileOutput()
(virtual) destructor
bool personApplies(const MSTransportable &p, int dir) const
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Base class for objects which have an id.
Definition: Named.h:54
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
Representation of a vehicle, person, or container.