20 #ifndef GNEAttributeCarrier_h 21 #define GNEAttributeCarrier_h 113 std::vector<SumoXMLAttr>
getAttrs()
const;
116 const std::string
getID()
const;
224 static T
parse(
const std::string&
string);
229 return canParse<T>(string) && parse<T>(
string) > 0;
233 static bool isValidID(
const std::string& value);
254 template <
typename T>
257 std::string parsedAttribute =
"0";
261 std::string additionalOfWarningMessage;
263 additionalOfWarningMessage =
toString(tag) +
" with ID '" +
toString(objectid) +
"'";
265 additionalOfWarningMessage =
toString(tag);
270 parsedAttribute = attrs.
get<std::string>(attribute, objectid, ok,
false);
272 if (ok && !canParse<T>(parsedAttribute)) {
275 std::string errorFormat;
277 if (
isInt(tag, attribute)) {
278 if (canParse<int>(parsedAttribute)) {
280 int parsedIntAttribute = parse<int>(parsedAttribute);
281 if (
isPositive(tag, attribute) && parsedIntAttribute < 0) {
282 errorFormat =
"Cannot be negative; ";
286 errorFormat =
"Cannot be parsed to int; ";
292 if (canParse<double>(parsedAttribute)) {
294 double parsedSumoRealAttribute = parse<double>(parsedAttribute);
295 if (
isPositive(tag, attribute) && parsedSumoRealAttribute < 0) {
296 errorFormat =
"Cannot be negative; ";
300 errorFormat =
"Cannot be parsed to float; ";
305 if (
isTime(tag, attribute)) {
306 if (canParse<double>(parsedAttribute)) {
308 double parsedSumoRealAttribute = parse<double>(parsedAttribute);
309 if (parsedSumoRealAttribute < 0) {
310 errorFormat =
"Time cannot be negative; ";
314 errorFormat =
"Cannot be parsed to time; ";
319 if (
isColor(tag, attribute) && !canParse<RGBColor>(parsedAttribute)) {
320 errorFormat =
"Invalid RGB format or named color; ";
325 errorFormat =
"Filename contains invalid characters; ";
330 errorFormat =
"Is not a part of defined set of Vehicle Classes; ";
334 errorFormat =
"Is not a part of defined set of Gui Vehicle Shapes; ";
340 parsedAttribute =
toString(getDefaultValue<T>(tag, attribute));
344 additionalOfWarningMessage +
" is invalid; " + errorFormat +
"Default value '" +
toString(parsedAttribute) +
"' will be used.");
348 additionalOfWarningMessage +
" is invalid; " + errorFormat +
"" +
toString(tag) +
" cannot be created");
350 parsedAttribute =
"0";
357 parsedAttribute =
toString(getDefaultValue<T>(tag, attribute));
361 additionalOfWarningMessage +
" is missing; Default value '" +
toString(parsedAttribute) +
"' will be used.");
365 additionalOfWarningMessage +
" is missing; " +
toString(tag) +
" cannot be created");
371 return parse<T>(parsedAttribute);
440 static std::map<SumoXMLTag, std::map<SumoXMLAttr, std::vector<std::string> > >
myDiscreteChoices;
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myColorAttrs
map with the color attributes
SumoXMLTag
Numbers representing SUMO-XML - element names.
static bool isPositive(const std::string &string)
true if a positive number of type T can be parsed from string
static bool isFloat(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical of type float
static std::string getAttributeType(SumoXMLTag tag, SumoXMLAttr attr)
get type of attribute
GNEAttributeCarrier(SumoXMLTag tag, GUIIcon icon)
Constructor.
const SumoXMLTag myTag
the xml tag to which this attribute carrier corresponds
std::vector< SumoXMLAttr > getAttrs() const
get vector of attributes
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
static std::map< SumoXMLTag, std::map< SumoXMLAttr, std::string > > myAttrDefinitions
map with the definition of attributes
static bool isDiscrete(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is Discrete
GUIIcon
An enumeration of icons used by the gui applications.
static std::vector< SumoXMLTag > myAllowedShapeTags
vector with the allowed tags of shapes
static const std::vector< SumoXMLTag > & allowedShapeTags()
get all editable for tag shape elements
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myPositiveAttrs
map with the positive attributes
static const std::vector< SumoXMLTag > & allowedNetElementsTags()
get all editable for tag net elements
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myUniqueAttrs
map with the unique attributes (i.e. attributes without default values)
static std::map< SumoXMLTag, std::map< SumoXMLAttr, std::vector< std::string > > > myDiscreteChoices
map with the values of discrete choices
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myBoolAttrs
map with the boolean attributes
static const std::string LOADED
feature is still unchanged after being loaded (implies approval)
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myProbabilityAttrs
map with the probability attributes
static int getHigherNumberOfAttributes()
return the number of attributes of the tag with the most highter number of attributes ...
GUIIcon myIcon
icon associated to this AC
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myTimeAttrs
map with the attributes of type time
static bool isPositive(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is only Positive (i.e. cannot take negative values)
A NBNetBuilder extended by visualisation and editing capabilities.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static std::map< SumoXMLTag, std::vector< std::pair< SumoXMLAttr, std::string > > > _allowedAttributes
map with the allowed attributes and their default values
static std::vector< SumoXMLTag > myBlockShapeTags
vector with the allowed tags that can block their shapes
static bool isValidFilename(const std::string &value)
true if value is a valid file value
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
static const std::vector< std::pair< SumoXMLAttr, std::string > > & allowedAttributes(SumoXMLTag tag)
get all editable attributes for tag and their default values.
static T parseAttributeFromXML(const SUMOSAXAttributes &attrs, const char *objectid, const SumoXMLTag tag, const SumoXMLAttr attribute, bool &abort, bool report=true)
Parse attribute from XML and show warnings if there are problems parsing it.
#define WRITE_WARNING(msg)
static std::vector< SumoXMLTag > myAllowedNetElementTags
vector with the allowed tags of netElements
static bool isString(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is of type string
static std::vector< SumoXMLTag > allowedTags()
get all editable for tag elements of all types
static const std::vector< std::string > & discreteChoices(SumoXMLTag tag, SumoXMLAttr attr)
return a list of discrete choices for this attribute or an empty vector
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myListAttrs
map with the attributes of type list
static bool isInt(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical or type int
the function-object for an editing operation (abstract base)
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
static const std::string MODIFIED
feature has been manually modified (implies approval)
static bool isTime(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is time
static bool isNonEditable(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is non editable
static std::vector< SumoXMLTag > myBlockMovementTags
vector with the allowed tags that can block their movement
static std::vector< SumoXMLTag > myAllowedAdditionalTags
vector with the allowed tags of additionals
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool hasAttribute(SumoXMLTag tag, SumoXMLAttr attr)
check if an element with certain tag has a certain attribute
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
static bool canBlockMovement(SumoXMLTag tag)
return true if element tag can block their movement
Encapsulated SAX-Attributes.
static bool hasDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
check if attribute of an element has a default avlue
static const double INVALID_POSITION
default value for invalid positions (used by POIs and Polygons)
static bool isColor(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is of type color for a certain tag
static bool isFilename(SumoXMLTag tag, SumoXMLAttr attr)
whether a string attribute is a filename
static T getDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
return the default value of the attribute of an element
const std::string getID() const
function to support debugging
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myNonEditableAttrs
map with the non-editable attributes
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
virtual ~GNEAttributeCarrier()
Destructor.
static bool isUnique(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is unique (may not be edited for a multi-selection and don't have a default valu...
static bool canParse(const std::string &string)
true if a number of type T can be parsed from string
static int myMaxNumAttribute
maximum number of attributes of all tags
FXIcon * getIcon() const
get FXIcon assigned to this object
static bool isProbability(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is a probability (i.e. oly can values between [0, 1])
static const std::vector< SumoXMLTag > & allowedAdditionalTags()
get all editable for tag additional elements
virtual std::string getAttribute(SumoXMLAttr key) const =0
This functions has to be implemented in allGNEAttributeCarrier.
static const std::string APPROVED
feature has been approved but not changed (i.e. after being reguessed)
static bool isBool(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is of type bool for a certain tag
static std::string getDefinition(SumoXMLTag tag, SumoXMLAttr attr)
return definition of a certain SumoXMLAttr
static bool discreteCombinableChoices(SumoXMLTag tag, SumoXMLAttr attr)
return whether the given attribute allows for a combination of discrete values
SumoXMLTag getTag() const
get XML Tag assigned to this object
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static bool isNumerical(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical (int or float)
GUIIcon getGUIIcon() const
get GUI icon assigned to this object
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myNumericalIntAttrs
map with the numerical attributes of type Int
static T parse(const std::string &string)
parses a number of type T from string
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myNumericalFloatAttrs
map with the numerical attributes of type Float
static bool canBlockShape(SumoXMLTag tag)
return true if element tag can block their shape
static std::map< SumoXMLTag, SumoXMLTag > myAllowedAdditionalWithParentTags
map with the allowed tags of additionals with parent and their parent
static bool isList(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is of type bool
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myFileAttrs
map with the empty attributes