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.org/sumo
3 // Copyright (C) 2001-2022 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>
34 #include <microsim/MSNet.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class OutputDevice;
41 class GUIDetectorWrapper;
42 class SUMOTrafficObject;
43 class MSTransportable;
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 int detectPersons = false);
66 
68  MSDetectorFileOutput(const std::string& id, const std::set<std::string>& vTypes, const int detectPersons = false);
69 
70 
72  virtual ~MSDetectorFileOutput() { }
73 
74 
77 
84  virtual void writeXMLOutput(OutputDevice& dev,
85  SUMOTime startTime, SUMOTime stopTime) = 0;
86 
87 
96  virtual void writeXMLDetectorProlog(OutputDevice& dev) const = 0;
97 
98 
106  virtual void reset() { }
107 
108 
113  virtual void detectorUpdate(const SUMOTime step) {
114  UNUSED_PARAMETER(step);
115  }
116 
117 
124  return 0;
125  }
126 
127 
133  bool vehicleApplies(const SUMOTrafficObject& veh) const;
134 
135  bool personApplies(const MSTransportable& p, int dir) const;
136 
137 
142  bool isTyped() const {
143  return !myVehicleTypes.empty();
144  }
145 
146  const std::set<std::string>& getVehicleTypes() const {
147  return myVehicleTypes;
148  }
149 
150  inline bool detectPersons() const {
151  return myDetectPersons != 0;
152  }
153 
155  virtual void clearState() {};
156 
157 protected:
159  std::set<std::string> myVehicleTypes;
160 
162  const int myDetectPersons;
163 
164 private:
167 
170 
171 
172 };
@ DU_USER_DEFINED
@ DU_SUMO_INTERNAL
@ DU_TL_CONTROL
long long int SUMOTime
Definition: SUMOTime.h:32
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
Base of value-generating classes (detectors)
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Builds the graphical representation.
bool isTyped() const
Checks whether the detector is type specific.
MSDetectorFileOutput(const MSDetectorFileOutput &)
Invalidated copy constructor.
virtual void clearState()
Remove all vehicles before quick-loading state.
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
const int myDetectPersons
Whether pedestrians shall be detected instead of vehicles.
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.
MSDetectorFileOutput(const std::string &id, const std::string &vTypes, const int detectPersons=false)
Constructor.
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.
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.