Eclipse SUMO - Simulation of Urban MObility
GNEAttributeProperties.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 // Abstract Base class for attribute properties used in GNEAttributeCarrier
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class GNETagProperties;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
43 
44 public:
45 
47  enum AttrProperty {
48  INT = 1 << 0, // Attribute is an integer (Including Zero)
49  FLOAT = 1 << 1, // Attribute is a float
50  SUMOTIME = 1 << 2, // Attribute is a SUMOTime
51  BOOL = 1 << 3, // Attribute is boolean (0/1, true/false)
52  STRING = 1 << 4, // Attribute is a string
53  POSITION = 1 << 5, // Attribute is a position defined by doubles (x,y or x,y,z)
54  COLOR = 1 << 6, // Attribute is a color defined by a specifically word (Red, green) or by a special format (XXX,YYY,ZZZ)
55  VTYPE = 1 << 7, // Attribute corresponds to a Vtype or VTypeDistribution
56  VCLASS = 1 << 8, // Attribute is a VClass (passenger, bus, motorcicle...)
57  POSITIVE = 1 << 9, // Attribute is positive (Including Zero)
58  UNIQUE = 1 << 10, // Attribute is unique (cannot be edited in a selection of similar elements (ID, Position...)
59  FILENAME = 1 << 11, // Attribute is a filename (string that cannot contains certain characters)
60  DISCRETE = 1 << 12, // Attribute is discrete (only certain values are allowed)
61  PROBABILITY = 1 << 13, // Attribute is probability (only allowed values between 0 and 1, including both)
62  ANGLE = 1 << 14, // Attribute is an angle (only takes values between 0 and 360, including both, another value will be automatically reduced
63  LIST = 1 << 15, // Attribute is a list of other elements separated by spaces
64  SECUENCIAL = 1 << 16, // Attribute is a special sequence of elements (for example: secuencial lanes in Multi Lane E2 detectors)
65  DEFAULTVALUE = 1 << 17, // Attribute owns a static default value
66  SYNONYM = 1 << 18, // Attribute will be written with a different name in der XML
67  RANGE = 1 << 19, // Attribute only accept a range of elements (example: Probability [0,1])
68  EXTENDED = 1 << 20, // Attribute is extended (in Frame will not be shown, but is editable in a Dialog, see VType attributes)
69  UPDATEGEOMETRY = 1 << 21, // Attribute require update geometry at the end of function setAttribute(...)
70  ACTIVATABLE = 1 << 22, // Attribute can be switch on/off using a checkbox in frame
71  FLOWDEFINITION = 1 << 23, // Attribute is part of a flow definition (Number, vehsPerHour...)
72  AUTOMATICID = 1 << 24, // Attribute id can generate their own ID (used by additionals, vehicles, etc...)
73  COPYABLE = 1 << 25, // Attribute can be copied over other element with the same tagProperty (used for edge/lane templates)
74  };
75 
78 
80  GNEAttributeProperties(const SumoXMLAttr attribute, const int attributeProperty, const std::string& definition, std::string defaultValue = "");
81 
84 
86  void checkAttributeIntegrity() const;
87 
89  void setDiscreteValues(const std::vector<std::string>& discreteValues);
90 
92  void setDefaultActivated(const bool value);
93 
95  void setSynonym(const SumoXMLAttr synonym);
96 
98  void setRange(const double minimum, const double maximum);
99 
101  void setTagPropertyParent(GNETagProperties* tagPropertyParent);
102 
104  SumoXMLAttr getAttr() const;
105 
107  const std::string& getAttrStr() const;
108 
110  const GNETagProperties& getTagPropertyParent() const;
111 
113  int getPositionListed() const;
114 
116  const std::string& getDefinition() const;
117 
119  const std::string& getDefaultValue() const;
120 
122  bool getDefaultActivated() const;
123 
125  std::string getDescription() const;
126 
128  const std::vector<std::string>& getDiscreteValues() const;
129 
131  SumoXMLAttr getAttrSynonym() const;
132 
134  double getMinimumRange() const;
135 
137  double getMaximumRange() const;
138 
140  bool hasDefaultValue() const;
141 
143  bool hasAttrSynonym() const;
144 
146  bool hasAttrRange() const;
147 
149  bool isInt() const;
150 
152  bool isFloat() const;
153 
155  bool isSUMOTime() const;
156 
158  bool isBool() const;
159 
161  bool isString() const;
162 
164  bool isPosition() const;
165 
167  bool isProbability() const;
168 
170  bool isNumerical() const;
171 
173  bool isPositive() const;
174 
176  bool isColor() const;
177 
179  bool isVType() const;
180 
182  bool isFilename() const;
183 
185  bool isVClass() const;
186 
188  bool isSVCPermission() const;
189 
191  bool isList() const;
192 
194  bool isSecuential() const;
195 
197  bool isUnique() const;
198 
200  bool isDiscrete() const;
201 
203  bool isExtended() const;
204 
206  bool requireUpdateGeometry() const;
207 
209  bool isActivatable() const;
210 
212  bool isFlowDefinition() const;
213 
215  bool hasAutomaticID() const;
216 
218  bool isCopyable() const;
219 
220 private:
223 
226 
228  std::string myAttrStr;
229 
232 
234  std::string myDefinition;
235 
237  std::string myDefaultValue;
238 
240  bool myDefaultActivated = false;
241 
243  std::vector<std::string> myDiscreteValues;
244 
247 
249  double myMinimumRange = 0;
250 
252  double myMaximumRange = 0;
253 };
254 
255 /****************************************************************************/
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NOTHING
invalid attribute, must be the last one
double getMaximumRange() const
get maximum range
bool isVClass() const
return true if attribute is a VehicleClass
bool isProbability() const
return true if attribute is a probability
bool isColor() const
return true if attribute is a color
void setTagPropertyParent(GNETagProperties *tagPropertyParent)
set tag property parent
void setDiscreteValues(const std::vector< std::string > &discreteValues)
set discrete values
void setSynonym(const SumoXMLAttr synonym)
set synonim
double myMinimumRange
minimun Range
bool isSVCPermission() const
return true if attribute is a VehicleClass
AttrProperty
struct with the tag Properties
int getPositionListed() const
get position in list (used in frames for listing attributes with certain sort)
bool isBool() const
return true if attribute is boolean
const std::string & getAttrStr() const
get XML Attribute
std::string getDescription() const
return a description of attribute
bool myDefaultActivated
default activated (by default false)
bool isFlowDefinition() const
return true if attribute is part of a flow definition
bool isPosition() const
return true if attribute is a position
bool hasAttrRange() const
return true if Attr correspond to an element that only accept a range of values
bool getDefaultActivated() const
get default active value
bool isList() const
return true if attribute is a list
SumoXMLAttr myAttrSynonym
Attribute written in XML (If is SUMO_ATTR_NOTHING), original Attribute will be written)
bool isNumerical() const
return true if attribute is numerical (int or float)
bool isInt() const
return true if attribute is an integer
bool isDiscrete() const
return true if attribute is discrete
void setDefaultActivated(const bool value)
set default activated value
GNEAttributeProperties()
default constructor
bool isCopyable() const
return true if attribute ID is copyable
const std::string & getDefaultValue() const
get default value
const std::string & getDefinition() const
get default value
double getMinimumRange() const
get minimum range
bool hasAttrSynonym() const
return true if Attr correspond to an element that will be written in XML with another name
bool isVType() const
return true if attribute is a VType or vTypeDistribution
int myAttributeProperty
Property of attribute.
bool isUnique() const
return true if attribute is unique
double myMaximumRange
maxium Range
bool isString() const
return true if attribute is a string
bool isExtended() const
return true if attribute is extended
std::vector< std::string > myDiscreteValues
discrete values that can take this Attribute (by default empty)
SumoXMLAttr getAttrSynonym() const
get tag synonym
bool isFloat() const
return true if attribute is a float
void checkAttributeIntegrity() const
check Attribute integrity (For example, throw an exception if tag has a Float default value,...
void setRange(const double minimum, const double maximum)
set range
GNETagProperties * myTagPropertyParent
pointer to tagProperty parent
SumoXMLAttr myAttribute
XML Attribute.
std::string myDefinition
text with a definition of attribute
bool isSUMOTime() const
return true if attribute is a SUMOTime
std::string myDefaultValue
default value (by default empty)
bool hasDefaultValue() const
return true if attribute owns a default value
bool isActivatable() const
return true if attribute is activatable
bool requireUpdateGeometry() const
return true if attribute requires a update geometry in setAttribute(...)
bool isPositive() const
return true if attribute is positive
const std::vector< std::string > & getDiscreteValues() const
get discrete values
bool isFilename() const
return true if attribute is a filename
SumoXMLAttr getAttr() const
get XML Attribute
bool isSecuential() const
return true if attribute is sequential
const GNETagProperties & getTagPropertyParent() const
get reference to tagProperty parent
std::string myAttrStr
string with the Attribute in text format (to avoid unnecesaries toStrings(...) calls)
bool hasAutomaticID() const
return true if attribute ID can generate an automatic ID