Eclipse SUMO - Simulation of Urban MObility
GNEDemandElementFlow.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 /****************************************************************************/
18 // An auxiliar, asbtract class for flow elements (vehicles, person and containers)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <utils/geom/Position.h>
26 
27 // ===========================================================================
28 // class declaration
29 // ===========================================================================
30 
32 class GNEDemandElement;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
37 
39 
40 protected:
42  GNEDemandElementFlow(const GNEDemandElement* flowElement);
43 
45  GNEDemandElementFlow(const GNEDemandElement* flowElement, const SUMOVehicleParameter& vehicleParameters);
46 
49 
51  void drawFlowLabel(const Position& position, const double rotation, const double width, const double length, const double exaggeration) const;
52 
54  void writeFlowAttributes(const GNEDemandElement* flowElement, OutputDevice& device) const;
55 
58  /* @brief method for getting the Attribute of an XML key
59  * @param[in] key The attribute key
60  * @return string with the value associated to key
61  */
62  std::string getFlowAttribute(SumoXMLAttr key) const;
63 
64  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
65  * @param[in] key The attribute key
66  * @return double with the value associated to key
67  */
68  double getFlowAttributeDouble(SumoXMLAttr key) const;
69 
70  /* @brief method for setting the attribute and letting the object perform demand element changes
71  * @param[in] key The attribute key
72  * @param[in] value The new value
73  * @param[in] undoList The undoList on which to register changes
74  * @param[in] net optionally the GNENet to inform about gui updates
75  */
76  void setFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
77 
78  /* @brief method for setting the attribute and letting the object perform demand element changes
79  * @param[in] key The attribute key
80  * @param[in] value The new value
81  * @param[in] undoList The undoList on which to register changes
82  */
83  bool isValidFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value);
84 
85  /* @brief method for enable attribute
86  * @param[in] key The attribute key
87  * @param[in] undoList The undoList on which to register changes
88  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
89  */
90  void enableFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, GNEUndoList* undoList);
91 
92  /* @brief method for disable attribute
93  * @param[in] key The attribute key
94  * @param[in] undoList The undoList on which to register changes
95  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
96  */
97  void disableFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, GNEUndoList* undoList);
98 
99  /* @brief method for check if the value for certain attribute is set
100  * @param[in] key The attribute key
101  */
102  bool isFlowAttributeEnabled(SumoXMLAttr key) const;
103 
105  void setFlowAttribute(const GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value);
106 
108  void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value);
109 
110 private:
112  void setDefaultFlowAttributes(const GNEDemandElement* flowElement);
113 
115  std::string adjustDecimalValue(const double value) const;
116 
119 
122 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaultFlowAttributes(const GNEDemandElement *flowElement)
set flow default attributes
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
GNEDemandElementFlow & operator=(const GNEDemandElementFlow &)=delete
Invalidated assignment operator.
std::string adjustDecimalValue(const double value) const
adjust decimal value
GNEDemandElementFlow(const GNEDemandElementFlow &)=delete
Invalidated copy constructor.
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
std::string getFlowAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GNEDemandElementFlow(const GNEDemandElement *flowElement)
constructor
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Structure representing possible vehicle parameter.