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-2025 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#include <utils/geom/Position.h>
25
26// ===========================================================================
27// class declarations
28// ===========================================================================
29
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
35
37
38public:
39
41 enum class Property : int {
42 INT = 1 << 0, // Attribute is an integer (Including Zero)
43 FLOAT = 1 << 1, // Attribute is a float
44 SUMOTIME = 1 << 2, // Attribute is a SUMOTime
45 BOOL = 1 << 3, // Attribute is boolean (0/1, true/false)
46 STRING = 1 << 4, // Attribute is a string
47 POSITION = 1 << 5, // Attribute is a position defined by doubles (x,y or x,y,z)
48 COLOR = 1 << 6, // Attribute is a color defined by a specifically word (Red, green) or by a special format (XXX,YYY,ZZZ)
49 VTYPE = 1 << 7, // Attribute corresponds to a Vtype or VTypeDistribution
50 VCLASS = 1 << 8, // Attribute is a VClass (passenger, bus, motorcicle...)
51 POSITIVE = 1 << 9, // Attribute is positive (Including Zero)
52 UNIQUE = 1 << 10, // Attribute is unique (cannot be edited in a selection of similar elements (ID, Position...)
53 FILEOPEN = 1 << 11, // Attribute is a filename that opens an existent file
54 FILESAVE = 1 << 12, // Attribute is a filename that can create a new file
55 DISCRETE = 1 << 13, // Attribute is discrete (only certain values are allowed)
56 PROBABILITY = 1 << 14, // Attribute is probability (only allowed values between 0 and 1, including both)
57 ANGLE = 1 << 15, // Attribute is an angle (only takes values between 0 and 360, including both, another value will be automatically reduced
58 LIST = 1 << 16, // Attribute is a list of other elements separated by spaces
59 SECUENCIAL = 1 << 17, // Attribute is a special sequence of elements (for example: secuencial lanes in Multi Lane E2 detectors)
60 DEFAULTVALUE = 1 << 18, // Attribute owns a static default value
61 SYNONYM = 1 << 19, // Attribute will be written with a different name in der XML
62 RANGE = 1 << 20, // Attribute only accept a range of elements (example: Probability [0,1])
63 UPDATEGEOMETRY = 1 << 21, // Attribute require update geometry at the end of function setAttribute(...)
64 ACTIVATABLE = 1 << 22, // Attribute can be switch on/off using a checkbox in frame
65 FLOW = 1 << 23, // Attribute is part of a flow definition (Number, vehsPerHour...)
66 COPYABLE = 1 << 24, // Attribute can be copied over other element with the same tagProperty (used for edge/lane templates)
67 ALWAYSENABLED = 1 << 25, // Attribute cannot be disabled
68 SORTABLE = 1 << 26, // Attribute can be used for sort elements in dialog
69 NO_PROPERTY = 1 << 27, // No property defined
70 };
71
73 enum class Edit : int {
74 CREATEMODE = 1 << 0, // Attribute can be modified in create mode
75 EDITMODE = 1 << 1, // Attribute can be modified in edit mode
76 NETEDITEDITOR = 1 << 2, // Attribute can be edited only in netedit editor
77 EXTENDEDEDITOR = 1 << 3, // Attribute cannot be edited in editor, but is editable in extended Dialog
78 GEOEDITOR = 1 << 4, // Attribute can be edited only in geo editor
79 FLOWEDITOR = 1 << 5, // Attribute can be edited only in flow editor
80 DIALOGEDITOR = 1 << 6, // Attribute can be edited in dialog editor
81 NO_EDIT = 1 << 7, // No edit property defined
82 };
83
85 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
86 const Edit editProperty, const std::string& definition);
87
89 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
90 const Edit editProperty, const std::string& definition, const std::string& defaultValue);
91
93 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
94 const Edit editProperty, const std::string& definition, const std::string& defaultValueMask,
95 const std::string& defaultValue);
96
98 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const std::string& definition);
99
102
104 void checkAttributeIntegrity() const;
105
107 void setDiscreteValues(const std::vector<std::string>& discreteValues);
108
110 void setFilenameExtensions(const std::vector<std::string>& extensions);
111
113 void setDefaultActivated(const bool value);
114
116 void setSynonym(const SumoXMLAttr synonym);
117
119 void setRange(const double minimum, const double maximum);
120
122 void setTagPropertyParent(GNETagProperties* tagPropertyParent);
123
125 void setAlternativeName(const std::string& alternativeName);
126
128 SumoXMLAttr getAttr() const;
129
131 const std::string& getAttrStr() const;
132
135
137 int getPositionListed() const;
138
140 const std::string& getDefinition() const;
141
143 const std::string& getDefaultStringValue() const;
144
146 int getDefaultIntValue() const;
147
149 double getDefaultDoubleValue() const;
150
153
155 bool getDefaultBoolValue() const;
156
158 const RGBColor& getDefaultColorValue() const;
159
161 const Position& getDefaultPositionValue() const;
162
164 bool getDefaultActivated() const;
165
167 std::string getCategory() const;
168
170 std::string getDescription() const;
171
173 const std::vector<std::string>& getDiscreteValues() const;
174
176 const std::vector<std::string>& getFilenameExtensions() const;
177
180
182 double getMinimumRange() const;
183
185 double getMaximumRange() const;
186
188 bool hasDefaultValue() const;
189
191 bool hasAttrSynonym() const;
192
194 bool hasAttrRange() const;
195
197 bool isInt() const;
198
200 bool isFloat() const;
201
203 bool isSUMOTime() const;
204
206 bool isBool() const;
207
209 bool isString() const;
210
212 bool isPosition() const;
213
215 bool isProbability() const;
216
218 bool isAngle() const;
219
221 bool isNumerical() const;
222
224 bool isPositive() const;
225
227 bool isColor() const;
228
230 bool isVType() const;
231
233 bool isFileOpen() const;
234
236 bool isFileSave() const;
237
239 bool isVClass() const;
240
242 bool isSVCPermission() const;
243
245 bool isList() const;
246
248 bool isSecuential() const;
249
251 bool isUnique() const;
252
254 bool isDiscrete() const;
255
257 bool requireUpdateGeometry() const;
258
260 bool isActivatable() const;
261
263 bool isFlow() const;
264
266 bool isCopyable() const;
267
269 bool isAlwaysEnabled() const;
270
272 bool isSortable() const;
273
276
278 bool isBasicEditor() const;
279
281 bool isExtendedEditor() const;
282
284 bool isGeoEditor() const;
285
287 bool isFlowEditor() const;
288
290 bool isNeteditEditor() const;
291
293 bool isCreateMode() const;
294
296 bool isEditMode() const;
297
299 bool isDialogEditor() const;
300
302
303private:
306
309
311 std::string myAttrStr;
312
315
318
320 std::string myDefinition;
321
324
327
330
333
335 bool myDefaultBoolValue = false;
336
339
342
344 bool myDefaultActivated = false;
345
347 std::vector<std::string> myDiscreteValues;
348
350 std::vector<std::string> myFilenameExtensions;
351
354
356 double myMinimumRange = 0;
357
359 double myMaximumRange = 0;
360
362 void checkBuildConstraints() const;
363
365 void parseDefaultValues(const std::string& defaultValue, const bool overWritteDefaultString);
366
369
372
375};
376
379 return static_cast<GNEAttributeProperties::Property>(static_cast<int>(a) | static_cast<int>(b));
380}
381
384 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
385}
386
389 return static_cast<GNEAttributeProperties::Edit>(static_cast<int>(a) | static_cast<int>(b));
390}
391
394 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
395}
396
397/****************************************************************************/
constexpr GNEAttributeProperties::Property operator|(GNEAttributeProperties::Property a, GNEAttributeProperties::Property b)
override attribute parent bit operator
constexpr bool operator&(GNEAttributeProperties::Property a, GNEAttributeProperties::Property b)
override attribute parent bit operator
long long int SUMOTime
Definition GUI.h:36
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NOTHING
invalid attribute, must be the last one
GNEAttributeProperties(const GNEAttributeProperties &)=delete
Invalidated copy constructor.
double getMaximumRange() const
get maximum range
bool isBasicEditor() const
return true if this attribute can be edited in basic editor
bool isExtendedEditor() const
return true if this attribute cannot be edited in editor
bool isVClass() const
return true if attribute is a VehicleClass
void checkBuildConstraints() const
check build constraints
bool isProbability() const
return true if attribute is a probability
const std::string & getDefaultStringValue() const
get default value in string format
bool isFlowEditor() const
return true if this attribute can be edited only in flow editor
bool myDefaultBoolValue
default bool value
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
Position myDefaultPositionValue
get default position value
double myMinimumRange
minimun Range
bool isSVCPermission() const
return true if attribute is a VehicleClass
void setAlternativeName(const std::string &alternativeName)
set alternative name
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 in string format (can be updated using alternative name)
std::string getDescription() const
return a description of attribute
Edit myEditProperty
edit properties
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
const std::vector< std::string > & getFilenameExtensions() const
get filename extensions in string format used in open dialogs
SUMOTime getDefaultTimeValue() const
get default time value
bool getDefaultActivated() const
get default active value
bool isList() const
return true if attribute is a list
double getDefaultDoubleValue() const
get default double value
bool isAngle() const
return true if attribute is an angle
GNEAttributeProperties & operator=(const GNEAttributeProperties &src)=delete
Invalidated assignment operator.
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
void parseDefaultValues(const std::string &defaultValue, const bool overWritteDefaultString)
parse default values
bool isCopyable() const
return true if attribute is copyable
bool isFileOpen() const
return true if attribute is a filename open
int getDefaultIntValue() const
get default int value
void setFilenameExtensions(const std::vector< std::string > &extensions)
set discrete values
const GNETagProperties * myTagPropertyParent
pointer to tagProperty parent
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
bool isGeoEditor() const
return true if this attribute can be edited only in GEO editor
bool isUnique() const
return true if attribute is unique
bool isEditMode() const
return true if attribute can be modified in edit mode
SUMOTime myDefaultTimeValue
default time value
bool isCreateMode() const
return true if attribute can be modified in create mode
GNEAttributeProperties()=delete
invalidate default constructor
bool isSortable() const
return true if attribute can be used for sorting elements in dialogs
double myMaximumRange
maxium Range
bool isString() const
return true if attribute is a string
double myDefaultDoubleValue
default double value
std::vector< std::string > myDiscreteValues
discrete values that can take this Attribute (by default empty)
int myDefaultIntValue
default int value
SumoXMLAttr getAttrSynonym() const
get tag synonym
bool isFloat() const
return true if attribute is a float
const RGBColor & getDefaultColorValue() const
get default bool value
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
bool isDialogEditor() const
return true if attribute can be modified in dialog editor
SumoXMLAttr myAttribute
XML Attribute.
std::string myDefinition
text with a definition of attribute
const GNETagProperties * getTagPropertyParent() const
get reference to tagProperty parent
Property myAttributeProperty
attribute properties
bool isSUMOTime() const
return true if attribute is a SUMOTime
bool hasDefaultValue() const
return true if attribute owns a default value
bool isFileSave() const
return true if attribute is a filename save
bool isFlow() const
return true if attribute is part of a flow definition
bool isActivatable() const
return true if attribute is activatable
RGBColor myDefaultColorValue
get default bool value
std::string getCategory() const
return category (based on Edit)
bool getDefaultBoolValue() const
get default bool value
bool requireUpdateGeometry() const
return true if attribute requires a update geometry in setAttribute(...)
bool isPositive() const
return true if attribute is positive
std::vector< std::string > myFilenameExtensions
filename extensions used in open dialogs (by default empty)
bool isNeteditEditor() const
return true if this attribute can be edited only in netedit editor
Edit
enum class with all edit modes
const std::vector< std::string > & getDiscreteValues() const
get discrete values
const Position & getDefaultPositionValue() const
get default position value
bool isAlwaysEnabled() const
return true if attribute is always enabled
SumoXMLAttr getAttr() const
get XML Attribute
bool isSecuential() const
return true if attribute is sequential
Property
enum class with all attribute properties
std::string myAttrStr
string with the Attribute in text format (to avoid unnecesaries toStrings(...) calls)
std::string myDefaultStringValue
default string value
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
static const RGBColor INVISIBLE
Definition RGBColor.h:198