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  };
74 
77 
79  GNEAttributeProperties(const SumoXMLAttr attribute, const int attributeProperty, const std::string& definition, std::string defaultValue = "");
80 
83 
85  void checkAttributeIntegrity() const;
86 
88  void setDiscreteValues(const std::vector<std::string>& discreteValues);
89 
91  void setDefaultActivated(const bool value);
92 
94  void setSynonym(const SumoXMLAttr synonym);
95 
97  void setRange(const double minimum, const double maximum);
98 
100  void setTagPropertyParent(GNETagProperties* tagPropertyParent);
101 
103  SumoXMLAttr getAttr() const;
104 
106  const std::string& getAttrStr() const;
107 
109  const GNETagProperties& getTagPropertyParent() const;
110 
112  int getPositionListed() const;
113 
115  const std::string& getDefinition() const;
116 
118  const std::string& getDefaultValue() const;
119 
121  bool getDefaultActivated() const;
122 
124  std::string getDescription() const;
125 
127  const std::vector<std::string>& getDiscreteValues() const;
128 
130  SumoXMLAttr getAttrSynonym() const;
131 
133  double getMinimumRange() const;
134 
136  double getMaximumRange() const;
137 
139  bool hasDefaultValue() const;
140 
142  bool hasAttrSynonym() const;
143 
145  bool hasAttrRange() const;
146 
148  bool isInt() const;
149 
151  bool isFloat() const;
152 
154  bool isSUMOTime() const;
155 
157  bool isBool() const;
158 
160  bool isString() const;
161 
163  bool isPosition() const;
164 
166  bool isProbability() const;
167 
169  bool isNumerical() const;
170 
172  bool isPositive() const;
173 
175  bool isColor() const;
176 
178  bool isVType() const;
179 
181  bool isFilename() const;
182 
184  bool isVClass() const;
185 
187  bool isSVCPermission() const;
188 
190  bool isList() const;
191 
193  bool isSecuential() const;
194 
196  bool isUnique() const;
197 
199  bool isDiscrete() const;
200 
202  bool isExtended() const;
203 
205  bool requireUpdateGeometry() const;
206 
208  bool isActivatable() const;
209 
211  bool isFlowDefinition() const;
212 
214  bool hasAutomaticID() const;
215 
216 private:
219 
222 
224  std::string myAttrStr;
225 
228 
230  std::string myDefinition;
231 
233  std::string myDefaultValue;
234 
236  bool myDefaultActivated = false;
237 
239  std::vector<std::string> myDiscreteValues;
240 
243 
245  double myMinimumRange = 0;
246 
248  double myMaximumRange = 0;
249 };
250 
251 /****************************************************************************/
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
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