19 #ifndef GNEAttributeCarrier_h 20 #define GNEAttributeCarrier_h 128 std::vector<SumoXMLAttr>
getAttrs()
const;
131 const std::string
getID()
const;
245 static T
parse(
const std::string&
string);
250 return canParse<T>(string) && parse<T>(
string) > 0;
254 static bool isValidID(
const std::string& value);
275 template <
typename T>
277 bool parsedOk =
true;
278 std::string defaultValue, parsedAttribute;
280 std::string additionalOfWarningMessage;
281 if (objectID !=
"") {
282 additionalOfWarningMessage =
toString(tag) +
" with ID '" + objectID +
"'";
284 additionalOfWarningMessage =
toString(tag);
289 }
else if (
isColor(tag, attribute)) {
290 defaultValue =
"BLACK";
295 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
297 if (parsedOk && !canParse<T>(parsedAttribute)) {
299 parsedAttribute = defaultValue;
302 std::string errorFormat;
305 if (parsedAttribute.empty()) {
306 errorFormat =
"ID cannot be empty; ";
308 }
else if (
isValidID(parsedAttribute) ==
false) {
309 errorFormat =
"'" + parsedAttribute +
"' contains invalid characters; ";
314 if (
isInt(tag, attribute)) {
315 if (canParse<int>(parsedAttribute)) {
317 int parsedIntAttribute = parse<int>(parsedAttribute);
318 if (
isPositive(tag, attribute) && parsedIntAttribute < 0) {
319 errorFormat =
"Cannot be negative; ";
322 }
else if (canParse<double>(parsedAttribute)) {
323 errorFormat =
"Float cannot be reinterpreted as int; ";
326 errorFormat =
"Cannot be parsed to int; ";
332 if (canParse<double>(parsedAttribute)) {
334 if (
isPositive(tag, attribute) && parse<double>(parsedAttribute) < 0) {
335 errorFormat =
"Cannot be negative; ";
339 errorFormat =
"Cannot be parsed to float; ";
344 if (
isTime(tag, attribute)) {
345 if (canParse<double>(parsedAttribute)) {
347 if (parse<double>(parsedAttribute) < 0) {
348 errorFormat =
"Time cannot be negative; ";
352 errorFormat =
"Cannot be parsed to time; ";
357 if (
isColor(tag, attribute) && !canParse<RGBColor>(parsedAttribute)) {
358 errorFormat =
"Invalid RGB format or named color; ";
363 errorFormat =
"Filename contains invalid characters; ";
368 errorFormat =
"List of VClasses isn't valid; ";
373 errorFormat =
"Is not a part of defined set of Vehicle Classes; ";
377 errorFormat =
"Is not a part of defined set of Gui Vehicle Shapes; ";
381 errorFormat =
"RouteProbe ID contains invalid characters; ";
388 parsedAttribute =
toString(getDefaultValue<T>(tag, attribute));
392 additionalOfWarningMessage +
" is invalid; " + errorFormat +
"Default value '" +
toString(parsedAttribute) +
"' will be used.");
396 additionalOfWarningMessage +
" is invalid; " + errorFormat +
toString(tag) +
" cannot be created");
400 parsedAttribute = defaultValue;
406 parsedAttribute =
toString(getDefaultValue<T>(tag, attribute));
410 additionalOfWarningMessage +
" is missing; Default value '" +
toString(parsedAttribute) +
"' will be used.");
414 additionalOfWarningMessage +
" is missing; " +
toString(tag) +
" cannot be created");
418 parsedAttribute = defaultValue;
422 return parse<T>(parsedAttribute);
453 static std::string
parseGNEEdges(
const std::vector<GNEEdge*>& edges);
458 static std::string
parseGNELanes(
const std::vector<GNELane*>& lanes);
533 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
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 T parseAttributeFromXML(const SUMOSAXAttributes &attrs, const std::string &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.
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)
FXIcon * getIcon() const
get FXIcon assigned to this object
A NBNetBuilder extended by visualisation and editing capabilities.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
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 std::vector< GNEEdge * > parseGNEEdges(GNENet *net, const std::string &value)
parse string into vector of GNEEdges
virtual std::string getAttribute(SumoXMLAttr key) const =0
This functions has to be implemented in all GNEAttributeCarriers.
static const std::vector< std::pair< SumoXMLAttr, std::string > > & allowedAttributes(SumoXMLTag tag)
get all editable attributes for tag and their default values.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#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 isVClass(SumoXMLTag tag, SumoXMLAttr attr)
whether a string attribute is a list of Vehicle Classes
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
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
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 bool checkGNELanesValid(GNENet *net, const std::string &value, bool report)
check if a list of Lane IDs is valid
static T getDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
return the default value of the attribute of an element
std::vector< SumoXMLAttr > getAttrs() const
get vector of attributes
const std::string getID() const
function to support debugging
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myNonEditableAttrs
map with the non-editable attributes
virtual ~GNEAttributeCarrier()
Destructor.
static std::vector< SumoXMLTag > myDialogTags
vector with the allowed tags that has a editor values
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
A road/street connecting two junctions (netedit-version)
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
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myVClassAttrs
map with the Vehicle Class attributes
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 getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
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 bool canOpenDialog(SumoXMLTag tag)
return true if element tag can open a values editor
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
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
GUIIcon getGUIIcon() const
get GUI icon assigned to this object
static std::vector< GNELane * > parseGNELanes(GNENet *net, const std::string &value)
parse string into vector of GNELanes
static bool isNumerical(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical (int or float)
static bool checkGNEEdgesValid(GNENet *net, const std::string &value, bool report)
check if a list of edge IDs is valid
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
const GUIGlObject * getGUIGLObject() const
get const pointer to GUIGlObject vinculated with this Attribute Carrier
SumoXMLTag getTag() const
get XML Tag assigned to this object
static std::map< SumoXMLTag, std::set< SumoXMLAttr > > myFileAttrs
map with the file attributes