Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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// ===========================================================================
36
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
41
43
44public:
45
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 FLOW = 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 ALWAYSENABLED = 1 << 26, // Attribute cannot be disabled
75 GEO = 1 << 27, // Attribute is of type GEO
76 NETEDIT = 1 << 28, // Attribute is exclusive of netedit
77 };
78
81
83 GNEAttributeProperties(const SumoXMLAttr attribute, const int attributeProperty, const std::string& definition, std::string defaultValue = "");
84
87
89 void checkAttributeIntegrity() const;
90
92 void setDiscreteValues(const std::vector<std::string>& discreteValues);
93
95 void setDefaultActivated(const bool value);
96
98 void setSynonym(const SumoXMLAttr synonym);
99
101 void setRange(const double minimum, const double maximum);
102
104 void setTagPropertyParent(GNETagProperties* tagPropertyParent);
105
107 SumoXMLAttr getAttr() const;
108
110 const std::string& getAttrStr() const;
111
114
116 int getPositionListed() const;
117
119 const std::string& getDefinition() const;
120
122 const std::string& getDefaultValue() const;
123
125 bool getDefaultActivated() const;
126
128 std::string getDescription() const;
129
131 const std::vector<std::string>& getDiscreteValues() const;
132
135
137 double getMinimumRange() const;
138
140 double getMaximumRange() const;
141
143 bool hasDefaultValue() const;
144
146 bool hasAttrSynonym() const;
147
149 bool hasAttrRange() const;
150
152 bool isInt() const;
153
155 bool isFloat() const;
156
158 bool isSUMOTime() const;
159
161 bool isBool() const;
162
164 bool isString() const;
165
167 bool isPosition() const;
168
170 bool isProbability() const;
171
173 bool isNumerical() const;
174
176 bool isPositive() const;
177
179 bool isColor() const;
180
182 bool isVType() const;
183
185 bool isFilename() const;
186
188 bool isVClass() const;
189
191 bool isSVCPermission() const;
192
194 bool isList() const;
195
197 bool isSecuential() const;
198
200 bool isUnique() const;
201
203 bool isDiscrete() const;
204
206 bool isExtended() const;
207
209 bool requireUpdateGeometry() const;
210
212 bool isActivatable() const;
213
215 bool isFlow() const;
216
218 bool hasAutomaticID() const;
219
221 bool isCopyable() const;
222
224 bool isAlwaysEnabled() const;
225
227 bool isGEO() const;
228
230 bool isNetedit() const;
231
232private:
235
238
240 std::string myAttrStr;
241
244
246 std::string myDefinition;
247
249 std::string myDefaultValue;
250
252 bool myDefaultActivated = false;
253
255 std::vector<std::string> myDiscreteValues;
256
259
261 double myMinimumRange = 0;
262
264 double myMaximumRange = 0;
265};
266
267/****************************************************************************/
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 isGEO() const
return true if attribute is GEO
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 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 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,...
bool isNetedit() const
return true if attribute is exclusive of netedit
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 isFlow() const
return true if attribute is part of a flow definition
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 isAlwaysEnabled() const
return true if attribute is always enabled
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