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.org/sumo
3 // Copyright (C) 2001-2020 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 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GNETagProperties;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
40 
42 
43 public:
44 
46  enum AttrProperty {
47  INT = 1 << 0, // Attribute is an integer (Including Zero)
48  FLOAT = 1 << 1, // Attribute is a float
49  SUMOTIME = 1 << 2, // Attribute is a SUMOTime
50  BOOL = 1 << 3, // Attribute is boolean (0/1, true/false)
51  STRING = 1 << 4, // Attribute is a string
52  POSITION = 1 << 5, // Attribute is a position defined by doubles (x,y or x,y,z)
53  COLOR = 1 << 6, // Attribute is a color defined by a specifically word (Red, green) or by a special format (XXX,YYY,ZZZ)
54  VCLASS = 1 << 7, // Attribute is a VClass (passenger, bus, motorcicle...)
55  POSITIVE = 1 << 8, // Attribute is positive (Including Zero)
56  UNIQUE = 1 << 9, // Attribute is unique (cannot be edited in a selection of similar elements (ID, Position...)
57  FILENAME = 1 << 10, // Attribute is a filename (string that cannot contains certain characters)
58  DISCRETE = 1 << 11, // Attribute is discrete (only certain values are allowed)
59  PROBABILITY = 1 << 12, // Attribute is probability (only allowed values between 0 and 1, including both)
60  ANGLE = 1 << 13, // Attribute is an angle (only takes values between 0 and 360, including both, another value will be automatically reduced
61  LIST = 1 << 14, // Attribute is a list of other elements separated by spaces
62  SECUENCIAL = 1 << 15, // Attribute is a special sequence of elements (for example: secuencial lanes in Multi Lane E2 detectors)
63  XMLOPTIONAL = 1 << 16, // Attribute will not be written in XML file if current value is the same of his default Static/Mutable value
64  DEFAULTVALUESTATIC = 1 << 17, // Attribute owns a static default value
65  DEFAULTVALUEMUTABLE = 1 << 18, // Attribute owns a mutable default value (Default value depends of value of other attribute)
66  VCLASSES = 1 << 19, // Attribute is a combination of VClasses (allow/disallow)
67  SYNONYM = 1 << 20, // Attribute will be written with a different name in der XML
68  RANGE = 1 << 21, // Attribute only accept a range of elements (example: Probability [0,1])
69  EXTENDED = 1 << 22, // Attribute is extended (in Frame will not be shown, but is editable in a Dialog, see VType attributes)
70  UPDATEGEOMETRY = 1 << 23, // Attribute require update geometry at the end of function setAttribute(...)
71  ACTIVATABLE = 1 << 24, // Attribute can be switch on/off using a checkbox in frame
72  COMPLEX = 1 << 25, // Attribute is complex: Requiere a special function to check if the given value is valid
73  FLOWDEFINITION = 1 << 26, // Attribute is part of a flow definition (Number, vehsPerHour...)
74  };
75 
78 
80  GNEAttributeProperties(const SumoXMLAttr attribute, const int attributeProperty, const std::string& definition, std::string defaultValue = "");
81 
84 
87 
89  void setDiscreteValues(const std::vector<std::string>& discreteValues);
90 
92  void setSynonym(const SumoXMLAttr synonym);
93 
95  void setRange(const double minimum, const double maximum);
96 
98  void setTagPropertyParent(GNETagProperties* tagPropertyParent);
99 
101  SumoXMLAttr getAttr() const;
102 
104  const std::string& getAttrStr() const;
105 
107  const GNETagProperties& getTagPropertyParent() const;
108 
110  int getPositionListed() const;
111 
113  const std::string& getDefinition() const;
114 
116  const std::string& getDefaultValue() const;
117 
119  std::string getDescription() const;
120 
122  const std::vector<std::string>& getDiscreteValues() const;
123 
125  SumoXMLAttr getAttrSynonym() const;
126 
128  double getMinimumRange() const;
129 
131  double getMaximumRange() const;
132 
134  bool hasStaticDefaultValue() const;
135 
137  bool hasMutableDefaultValue() const;
138 
140  bool hasAttrSynonym() const;
141 
143  bool hasAttrRange() const;
144 
146  bool isInt() const;
147 
149  bool isFloat() const;
150 
152  bool isSUMOTime() const;
153 
155  bool isBool() const;
156 
158  bool isString() const;
159 
161  bool isposition() const;
162 
164  bool isProbability() const;
165 
167  bool isNumerical() const;
168 
170  bool isPositive() const;
171 
173  bool isColor() const;
174 
176  bool isFilename() const;
177 
179  bool isVClass() const;
180 
182  bool isSVCPermission() const;
183 
185  bool isList() const;
186 
188  bool isSecuential() const;
189 
191  bool isUnique() const;
192 
194  bool isOptional() const;
195 
197  bool isDiscrete() const;
198 
200  bool isVClasses() const;
201 
203  bool isExtended() const;
204 
206  bool requireUpdateGeometry() const;
207 
209  bool isActivatable() const;
210 
212  bool isComplex() const;
213 
215  bool isFlowDefinition() const;
216 
217 private:
220 
223 
225  std::string myAttrStr;
226 
229 
231  std::string myDefinition;
232 
234  std::string myDefaultValue;
235 
237  std::vector<std::string> myDiscreteValues;
238 
241 
244 
247 };
248 
249 /****************************************************************************/
250 
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double getMaximumRange() const
get maximum range
bool isVClass() const
return true if atribute is a VehicleClass
bool isProbability() const
return true if atribute is a probability
bool isColor() const
return true if atribute 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 atribute 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 atribute is boolean
const std::string & getAttrStr() const
get XML Attribute
bool hasMutableDefaultValue() const
return true if attribute owns a mutable default value
std::string getDescription() const
return a description of attribute
bool isFlowDefinition() const
return true if atribute is part of a flow definition
bool hasAttrRange() const
return true if Attr correspond to an element that only accept a range of values
bool isList() const
return true if atribute 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 atribute is numerical (int or float)
bool isInt() const
return true if atribute is an integer
bool isDiscrete() const
return true if atribute is discrete
bool isOptional() const
return true if atribute is optional (it will be written in XML only if his value is different of defa...
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 isComplex() const
return true if atribute is complex
bool hasAttrSynonym() const
return true if Attr correspond to an element that will be written in XML with another name
int myAttributeProperty
Property of attribute.
bool isUnique() const
return true if atribute is unique
double myMaximumRange
maxium Range
bool isString() const
return true if atribute is a string
bool hasStaticDefaultValue() const
return true if attribute owns a static default value
bool isExtended() const
return true if atribute is extended
void checkAttributeIntegrity()
check Attribute integrity (For example, throw an exception if tag has a Float default value,...
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 atribute is a float
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 isVClasses() const
return true if atribute is a list of VClasses
bool isSUMOTime() const
return true if atribute is a SUMOTime
std::string myDefaultValue
default value (by default empty)
bool isposition() const
return true if atribute is a position
bool isActivatable() const
return true if atribute is activatable
bool requireUpdateGeometry() const
return true if atribute requires a update geometry in setAttribute(...)
bool isPositive() const
return true if atribute is positive
const std::vector< std::string > & getDiscreteValues() const
get discrete values
bool isFilename() const
return true if atribute is a filename
SumoXMLAttr getAttr() const
get XML Attribute
bool isSecuential() const
return true if atribute 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)