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 NO_EDIT = 1 << 6, // No edit property defined
80 };
81
83 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
84 const Edit editProperty, const std::string& definition);
85
87 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
88 const Edit editProperty, const std::string& definition, const std::string& defaultValue);
89
91 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const Property attributeProperty,
92 const Edit editProperty, const std::string& definition, const std::string& defaultValueMask,
93 const std::string& defaultValue);
94
96 GNEAttributeProperties(GNETagProperties* tagProperties, const SumoXMLAttr attribute, const std::string& definition);
97
100
102 void checkAttributeIntegrity() const;
103
105 void setDiscreteValues(const std::vector<std::string>& discreteValues);
106
108 void setFilenameExtensions(const std::string& extensions);
109
111 void setDefaultActivated(const bool value);
112
114 void setSynonym(const SumoXMLAttr synonym);
115
117 void setRange(const double minimum, const double maximum);
118
120 void setTagPropertyParent(GNETagProperties* tagPropertyParent);
121
123 void setAlternativeName(const std::string& alternativeName);
124
126 SumoXMLAttr getAttr() const;
127
129 const std::string& getAttrStr() const;
130
133
135 int getPositionListed() const;
136
138 const std::string& getDefinition() const;
139
141 const std::string& getDefaultStringValue() const;
142
144 int getDefaultIntValue() const;
145
147 double getDefaultDoubleValue() const;
148
151
153 bool getDefaultBoolValue() const;
154
156 const RGBColor& getDefaultColorValue() const;
157
159 const Position& getDefaultPositionValue() const;
160
162 bool getDefaultActivated() const;
163
165 std::string getCategory() const;
166
168 std::string getDescription() const;
169
171 const std::vector<std::string>& getDiscreteValues() const;
172
174 const std::string& getFilenameExtensions() const;
175
178
180 double getMinimumRange() const;
181
183 double getMaximumRange() const;
184
186 bool hasDefaultValue() const;
187
189 bool hasAttrSynonym() const;
190
192 bool hasAttrRange() const;
193
195 bool isInt() const;
196
198 bool isFloat() const;
199
201 bool isSUMOTime() const;
202
204 bool isBool() const;
205
207 bool isString() const;
208
210 bool isPosition() const;
211
213 bool isProbability() const;
214
216 bool isAngle() const;
217
219 bool isNumerical() const;
220
222 bool isPositive() const;
223
225 bool isColor() const;
226
228 bool isVType() const;
229
231 bool isFileOpen() const;
232
234 bool isFileSave() const;
235
237 bool isVClass() const;
238
240 bool isSVCPermission() const;
241
243 bool isList() const;
244
246 bool isSecuential() const;
247
249 bool isUnique() const;
250
252 bool isDiscrete() const;
253
255 bool requireUpdateGeometry() const;
256
258 bool isActivatable() const;
259
261 bool isFlow() const;
262
264 bool isCopyable() const;
265
267 bool isAlwaysEnabled() const;
268
271
273 bool isBasicEditor() const;
274
276 bool isExtendedEditor() const;
277
279 bool isGeoEditor() const;
280
282 bool isFlowEditor() const;
283
285 bool isNeteditEditor() const;
286
288 bool isCreateMode() const;
289
291 bool isEditMode() const;
292
294
295private:
298
301
303 std::string myAttrStr;
304
307
310
312 std::string myDefinition;
313
316
319
322
325
327 bool myDefaultBoolValue = false;
328
331
334
336 bool myDefaultActivated = false;
337
339 std::vector<std::string> myDiscreteValues;
340
343
346
348 double myMinimumRange = 0;
349
351 double myMaximumRange = 0;
352
354 void checkBuildConstraints() const;
355
357 void parseDefaultValues(const std::string& defaultValue, const bool overWritteDefaultString);
358
361
364
367};
368
371 return static_cast<GNEAttributeProperties::Property>(static_cast<int>(a) | static_cast<int>(b));
372}
373
376 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
377}
378
381 return static_cast<GNEAttributeProperties::Edit>(static_cast<int>(a) | static_cast<int>(b));
382}
383
386 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
387}
388
389/****************************************************************************/
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
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
std::string myFilenameExtensions
filename extensions used in open dialogs (by default empty)
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
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
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
void setFilenameExtensions(const std::string &extensions)
set discrete values
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
const std::string & getFilenameExtensions() const
get filename extensions in string format used in open dialogs
bool requireUpdateGeometry() const
return true if attribute requires a update geometry in setAttribute(...)
bool isPositive() const
return true if attribute is positive
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:319
static const RGBColor INVISIBLE
Definition RGBColor.h:198