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 NO_PROPERTY = 1 << 26, // No property defined
69 };
70
72 enum class Edit : int {
73 CREATEMODE = 1 << 0, // Attribute can be modified in create mode
74 EDITMODE = 1 << 1, // Attribute can be modified in edit mode
75 NETEDITEDITOR = 1 << 2, // Attribute can be edited only in netedit editor
76 EXTENDEDEDITOR = 1 << 3, // Attribute cannot be edited in editor, but is editable in extended Dialog
77 GEOEDITOR = 1 << 4, // Attribute can be edited only in geo editor
78 FLOWEDITOR = 1 << 5, // Attribute can be edited only in flow editor
79 DIALOGEDITOR = 1 << 6, // Attribute can be edited in dialog editor
80 NO_EDIT = 1 << 7, // No edit property defined
81 };
82
84 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
85 const Edit editProperty, const std::string& definition);
86
88 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
89 const Edit editProperty, const std::string& definition, const std::string& defaultValue);
90
92 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
93 const Edit editProperty, const std::string& definition, const std::string& defaultValueMask,
94 const std::string& defaultValue);
95
97 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const std::string& definition);
98
101
103 void checkAttributeIntegrity() const;
104
106 void setDiscreteValues(const std::vector<std::string>& discreteValues);
107
109 void setFilenameExtensions(const std::vector<std::string>& extensions);
110
112 void setDefaultActivated(const bool value);
113
115 void setSynonym(const SumoXMLAttr synonym);
116
118 void setRange(const double minimum, const double maximum);
119
121 void setTagPropertyParent(GNETagProperties* tagPropertyParent);
122
124 void setAlternativeName(const std::string& alternativeName);
125
127 SumoXMLAttr getAttr() const;
128
130 const std::string& getAttrStr() const;
131
134
136 int getPositionListed() const;
137
139 const std::string& getDefinition() const;
140
142 const std::string& getDefaultStringValue() const;
143
145 int getDefaultIntValue() const;
146
148 double getDefaultDoubleValue() const;
149
152
154 bool getDefaultBoolValue() const;
155
157 const RGBColor& getDefaultColorValue() const;
158
160 const Position& getDefaultPositionValue() const;
161
163 bool getDefaultActivated() const;
164
166 std::string getCategory() const;
167
169 std::string getDescription() const;
170
172 const std::vector<std::string>& getDiscreteValues() const;
173
175 const std::vector<std::string>& getFilenameExtensions() const;
176
179
181 double getMinimumRange() const;
182
184 double getMaximumRange() const;
185
187 bool hasDefaultValue() const;
188
190 bool hasAttrSynonym() const;
191
193 bool hasAttrRange() const;
194
196 bool isInt() const;
197
199 bool isFloat() const;
200
202 bool isSUMOTime() const;
203
205 bool isBool() const;
206
208 bool isString() const;
209
211 bool isPosition() const;
212
214 bool isProbability() const;
215
217 bool isAngle() const;
218
220 bool isNumerical() const;
221
223 bool isPositive() const;
224
226 bool isColor() const;
227
229 bool isVType() const;
230
232 bool isFileOpen() const;
233
235 bool isFileSave() const;
236
238 bool isVClass() const;
239
241 bool isSVCPermission() const;
242
244 bool isList() const;
245
247 bool isSecuential() const;
248
250 bool isUnique() const;
251
253 bool isDiscrete() const;
254
256 bool requireUpdateGeometry() const;
257
259 bool isActivatable() const;
260
262 bool isFlow() const;
263
265 bool isCopyable() const;
266
268 bool isAlwaysEnabled() const;
269
272
274 bool isBasicEditor() const;
275
277 bool isExtendedEditor() const;
278
280 bool isGeoEditor() const;
281
283 bool isFlowEditor() const;
284
286 bool isNeteditEditor() const;
287
289 bool isCreateMode() const;
290
292 bool isEditMode() const;
293
295 bool isDialogEditor() const;
296
298
299private:
302
305
307 std::string myAttrStr;
308
311
314
316 std::string myDefinition;
317
320
323
326
329
331 bool myDefaultBoolValue = false;
332
335
338
340 bool myDefaultActivated = false;
341
343 std::vector<std::string> myDiscreteValues;
344
346 std::vector<std::string> myFilenameExtensions;
347
350
352 double myMinimumRange = 0;
353
355 double myMaximumRange = 0;
356
358 void checkBuildConstraints() const;
359
361 void parseDefaultValues(const std::string& defaultValue, const bool overWritteDefaultString);
362
365
368
371};
372
375 return static_cast<GNEAttributeProperties::Property>(static_cast<int>(a) | static_cast<int>(b));
376}
377
380 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
381}
382
385 return static_cast<GNEAttributeProperties::Edit>(static_cast<int>(a) | static_cast<int>(b));
386}
387
390 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
391}
392
393/****************************************************************************/
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
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