 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
16 #ifndef GNEAttributeCarrier_h
17 #define GNEAttributeCarrier_h
119 void setRange(
const double minimum,
const double maximum);
347 std::vector<AttributeProperties>::const_iterator
begin()
const;
350 std::vector<AttributeProperties>::const_iterator
end()
const;
623 const std::string
getID()
const;
629 static std::vector<SumoXMLTag>
allowedTags(
bool onlyDrawables);
653 static T
parse(
const std::string&
string);
659 parse<T>(net, value);
675 static std::string
parseIDs(
const std::vector<T>& ACs);
681 template <
typename T>
683 bool parsedOk =
true;
685 std::string defaultValue, parsedAttribute, warningMessage;
689 if (tagProperties.isAttributeDeprecated(attribute)) {
692 WRITE_WARNING(
"Attribute " +
toString(attribute) +
"' of " + tagProperties.getTagStr() +
" is deprecated and will not be loaded.");
698 if (objectID !=
"") {
699 warningMessage = tagProperties.getTagStr() +
" with ID '" + objectID +
"'";
701 warningMessage = tagProperties.getTagStr();
706 if (tagProperties.canBlockMovement()) {
708 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
710 if (!canParse<bool>(parsedAttribute)) {
713 return parse<T>(
"0");
716 return parse<T>(parsedAttribute);
719 throw ProcessError(
"Trying to parsing block movement attribute in an AC that cannot be moved");
727 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
729 if (!canParse<double>(parsedAttribute)) {
731 warningMessage +
" is invalid; Cannot be parsed to float; " + tagProperties.getTagStr() +
" cannot be created");
733 return parse<T>(
"0");
736 return parse<T>(parsedAttribute);
741 return parse<T>(
"0");
744 const auto& attrProperties = tagProperties.getAttributeProperties(attribute);
746 if (attrProperties.isNumerical() || attrProperties.isBool()) {
748 }
else if (attrProperties.isColor()) {
749 defaultValue =
"black";
750 }
else if (attrProperties.isposition()) {
751 defaultValue =
"0,0";
756 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
758 if (!
checkParsedAttribute(tagProperties, attrProperties, attribute, defaultValue, parsedAttribute, warningMessage)) {
761 }
else if (tagProperties.canMaskXYZPositions() && (attribute ==
SUMO_ATTR_POSITION)) {
768 if (attrProperties.isOptional()) {
769 parsedAttribute = attrProperties.getDefaultValue();
771 WRITE_WARNING(
"Essential " + attrProperties.getDescription() +
" attribute '" +
toString(attribute) +
"' of " +
772 warningMessage +
" is missing; " + tagProperties.getTagStr() +
" cannot be created");
776 parsedAttribute = defaultValue;
780 return parse<T>(parsedAttribute);
850 std::string& defaultValue, std::string& parsedAttribute, std::string& warningMessage);
854 const AttributeProperties& attrProperties, std::string& parsedAttribute, std::string& warningMessage);
void setSynonym(const SumoXMLAttr synonym)
set synonim
@ TAGPROPERTY_WRITECHILDRENSEPARATE
SumoXMLTag myTag
Sumo XML Tag vinculated wit this tag Property.
bool isProbability() const
return true if atribute is a probability
static void fillAttributeCarriers()
fill Attribute Carriers
bool isPerson() const
return true if tag correspond to a person element
FXIcon * getIcon() const
get FXIcon associated to this AC
GNEAttributeCarrier(const SumoXMLTag tag)
Constructor.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
bool isSUMOTime() const
return true if atribute is a SUMOTime
struct with the attribute Properties
SumoXMLTag myTagSynonym
Tag written in XML (If is SUMO_TAG_NOTHING), original Tag name will be written)
static TagProperties dummyTagProperty
dummy TagProperty used for reference some elements (for Example, dummyEdge)
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
static bool checkParsedAttribute(const TagProperties &tagProperties, const AttributeProperties &attrProperties, const SumoXMLAttr attribute, std::string &defaultValue, std::string &parsedAttribute, std::string &warningMessage)
parse and check attribute (note: This function is only to improve legilibility)
void addDeprecatedAttribute(SumoXMLAttr attr)
add deprecated Attribute
const std::string getID() const
function to support debugging
virtual void updateGeometry()=0
update pre-computed geometry information
#define WRITE_WARNING(msg)
bool isAdditional() const
return true if tag correspond to an additional
void checkAttributeIntegrity()
check Attribute integrity (For example, throw an exception if tag has a Float default value,...
bool isposition() const
return true if atribute is a position
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isPlacedInRTree() const
return true if Tag correspond to an element that has has to be placed in RTREE
bool isTAZ() const
return true if tag correspond to a TAZ
bool canMaskStartEndPos() const
return true if tag correspond to an element that can mask the attributes "start" and "end" position a...
bool isStoppingPlace() const
return true if tag correspond to a detector (Only used to group all stoppingPlaces in the output XML)
bool isOptional() const
return true if atribute is optional (it will be written in XML only if his value is different of defa...
@ ATTRPROPERTY_DEFAULTVALUEMUTABLE
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static void fillCommonFlowAttributes(SumoXMLTag currentTag)
fill common flow attributes (used by flows, routeFlows and personFlows)
static T parseAttributeFromXML(const SUMOSAXAttributes &attrs, const std::string &objectID, const SumoXMLTag tag, const SumoXMLAttr attribute, bool &abort)
Parse attribute from XML and show warnings if there are problems parsing it.
A NBNetBuilder extended by visualisation and editing capabilities.
bool isNetElement() const
return true if tag correspond to a netElement
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
bool isPositive() const
return true if atribute is positive
static void fillPersonStopElements()
fill PersonStop elements
bool canBeSortedManually() const
return true if Tag correspond to an element that can be sorted within their parent
static void fillShapes()
fill Shapes
std::vector< AttributeProperties >::const_iterator begin() const
get begin of attribute values (used for iterate)
@ TAGPROPERTY_NOPARAMETERS
bool isRoute() const
return true if tag correspond to a route element
bool isUnique() const
return true if atribute is unique
const std::string & getDefinition() const
get default value
virtual void selectAttributeCarrier(bool changeFlag=true)=0
bool isFloat() const
return true if atribute is a float
void setDiscreteValues(const std::vector< std::string > &discreteValues)
set discrete values
int myTagProperty
Attribute properties.
bool isStop() const
return true if tag correspond to a stop element
@ ATTRPROPERTY_FLOWDEFINITION
std::vector< AttributeProperties >::const_iterator end() const
get end of attribute values (used for iterate)
bool isShape() const
return true if tag correspond to a shape
bool isVehicleType() const
return true if tag correspond to a vehicle type element
@ TAGPROPERTY_MASKSTARTENDPOS
@ SUMO_TAG_NOTHING
invalid tag
TagProperties()
default constructor
bool hasGEOShape() const
return true if tag correspond to an element that can use a geo shape
@ ATTRPROPERTY_UPDATEGEOMETRY
void checkTagIntegrity() const
check Tag integrity (this include all their attributes)
bool hasMinimumNumberOfChildren() const
return true if tag correspond to an element that only have a limited number of children
std::string myTagStr
Sumo XML Tag vinculated wit this tag Property in String format.
static void fillAdditionals()
fill Additionals
virtual bool drawUsingSelectColor() const =0
check if attribute carrier must be drawn using selecting color.
bool canWriteChildrenSeparate() const
return true if tag correspond to an element that can sort their children automatic
@ ATTRPROPERTY_PROBABILITY
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string myDefaultValue
default value (by default empty)
static void fillDemandElements()
fill Demand Elements
std::string myAttrStr
string with the Attribute in text format (to avoid unnecesaries toStrings(...) calls)
bool requireUpdateGeometry() const
return true if atribute requires a update geometry in setAttribute(...)
@ TAGPROPERTY_MASKXYZPOSITION
@ TAGPROPERTY_CENTERAFTERCREATION
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isList() const
return true if atribute is a list
@ ATTRPROPERTY_DEFAULTVALUESTATIC
virtual void setEnabledAttribute(const int enabledAttributes)=0
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
static bool parseMaskedPositionAttribute(const SUMOSAXAttributes &attrs, const std::string &objectID, const TagProperties &tagProperties, const AttributeProperties &attrProperties, std::string &parsedAttribute, std::string &warningMessage)
parse and check masked (note: This function is only to improve legilibility)
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute attr
A road/street connecting two junctions (netedit-version)
bool canAutomaticSortChildren() const
return true if tag correspond to an element that can sort their children automatic
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
SumoXMLTag getTagSynonym() const
get tag synonym
bool isVehicle() const
return true if tag correspond to a vehicle element
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
static void fillCommonVehicleAttributes(SumoXMLTag currentTag)
fill common vehicle attributes (used by vehicles, trips, routeFlows and flows)
AttributeProperties()
default constructor
bool isFlowDefinition() const
return true if atribute is part of a flow definition
bool isAttributeDeprecated(SumoXMLAttr attr) const
return true if attribute of this tag is deprecated
bool canBlockShape() const
return true if tag correspond to an element that can block their shape
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
bool isFilename() const
return true if atribute is a filename
bool isActivatable() const
return true if atribute is activatable
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
static void fillStopElements()
fill Stop elements
SumoXMLAttr myAttrSynonym
Attribute written in XML (If is SUMO_ATTR_NOTHING), original Attribute will be written)
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
struct with the attribute Properties
bool isColor() const
return true if atribute is a color
static std::vector< SumoXMLTag > allowedTagsByCategory(int tagPropertyCategory, bool onlyDrawables)
get tags of all editable element types using TagProperty Type (TAGTYPE_NETELEMENT,...
static T parse(GNENet *net, const std::string &value)
parses a complex value of type T from string (use for list of edges, list of lanes,...
static void fillPersonElements()
fill Person Elements
AttrProperty
struct with the tag Properties
bool isDemandElement() const
return true if tag correspond to a demand element
bool hasGEOPosition() const
return true if tag correspond to an element that can use a geo position
static bool canParse(GNENet *net, const std::string &value, bool report)
true if a value of type T can be parsed from string
double myMaximumRange
maxium Range
@ TAGPROPERTY_AUTOMATICSORTING
SumoXMLTag getParentTag() const
if Tag owns a parent, return parent tag
@ TAGPROPERTY_GEOPOSITION
void addAttribute(const AttributeProperties &attributeProperty)
add attribute (duplicated attributed aren't allowed)
void setTagPropertyParent(TagProperties *tagPropertyParent)
set tag property parent
static std::map< SumoXMLTag, TagProperties > myTagProperties
map with the tags properties
const std::string & getAttrStr() const
get XML Attribute
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
the function-object for an editing operation (abstract base)
const std::string & getDefaultValue() const
get default value
@ TAGPROPERTY_MINIMUMCHILDREN
bool canBeReparent() const
return true if tag correspond to an element that can be reparent
double getMinimumRange() const
get minimum range
bool isWalk() const
return true if tag correspond to a walk element
std::vector< SumoXMLAttr > myDeprecatedAttributes
List with the deprecated Attributes.
std::string getAlternativeValueForDisabledAttributes(SumoXMLAttr key) const
~AttributeProperties()
destructor
static void fillVehicleElements()
fill vehicle elements
SumoXMLAttr getAttr() const
get XML Attribute
GUIIcon
An enumeration of icons used by the gui applications.
bool isSecuential() const
return true if atribute is sequential
bool isVClass() const
return true if atribute is a VehicleClass
GNEAttributeCarrier(const GNEAttributeCarrier &)=delete
Invalidated copy constructor.
double getMaximumRange() const
get maximum range
const TagProperties & getTagPropertyParent() const
get reference to tagProperty parent
bool canCenterCameraAfterCreation() const
return true if tag correspond to an element that center camera after creation
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
std::vector< AttributeProperties > myAttributeProperties
vector with the attribute values vinculated with this Tag
@ ATTRPROPERTY_SECUENCIAL
bool hasMutableDefaultValue() const
return true if attribute owns a mutable default value
TagProperties * myTagPropertyParent
pointer to tagProperty parent
bool hasStaticDefaultValue() const
return true if attribute owns a static default value
~TagProperties()
destructor
static const double INVALID_POSITION
invalid double position
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
bool isDiscrete() const
return true if atribute is discrete
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
bool isPersonTrip() const
return true if tag correspond to a person trip
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
static void fillCommonStopAttributes(SumoXMLTag currentTag)
fill stop person attributes (used by stops and personStps)
@ TAGPROPERTY_BLOCKMOVEMENT
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void fillCarFollowingModelAttributes(SumoXMLTag currentTag)
fill Car Following Model of Vehicle/Person Types
bool isPersonPlan() const
return true if tag correspond to a person plan
bool isSelectable() const
return true if tag correspond to a selectable element
@ ATTRPROPERTY_ACTIVATABLE
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
static std::vector< SumoXMLTag > allowedTags(bool onlyDrawables)
get tags of all editable element types
bool isVClasses() const
return true if atribute is a list of VClasses
const std::vector< std::string > & getDiscreteValues() const
get discrete values
bool isPersonStop() const
return true if tag correspond to a person stop element
bool hasTagSynonym() const
return true if tag correspond to an element that will be written in XML with another tag
GUIIcon myIcon
icon associated to this Tag
virtual ~GNEAttributeCarrier()
Destructor.
bool isBool() const
return true if atribute is boolean
static void fillLaneChangingModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
bool hasAttrSynonym() const
return true if Attr correspond to an element that will be written in XML with another name
bool canBlockMovement() const
return true if tag correspond to an element that can block their movement
@ GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool isNumerical() const
return true if atribute is numerical (int or float)
double myMinimumRange
minimun Range
bool isDrawable() const
return true if tag correspond to a drawable element
bool isDetector() const
return true if tag correspond to a shape (Only used to group all detectors in the XML)
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
static const std::string FEATURE_APPROVED
feature has been approved but not changed (i.e. after being reguessed)
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
bool hasParameters() const
return true if Tag correspond to an element that supports parameters "key1=value1|key2=value2|....
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
int getPositionListed() const
get position in list (used in frames for listing attributes with certain sort)
const AttributeProperties & getAttributeProperties(SumoXMLAttr attr) const
get attribute (throw error if doesn't exist)
static const TagProperties & getTagProperties(SumoXMLTag tag)
get Tag Properties
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
SumoXMLAttr myAttribute
XML Attribute.
bool canCloseShape() const
return true if tag correspond to an element that can close their shape
@ TAGPROPERTY_SORTINGCHILDREN
bool isExtended() const
return true if atribute is extended
the function-object for an editing operation (abstract base)
bool hasParent() const
return true if tag correspond to an element that can had another element as parent
bool isInt() const
return true if atribute is an integer
SumoXMLAttr getAttrSynonym() const
get tag synonym
bool isRide() const
return true if tag correspond to a ride element
const std::string & getTagStr() const
get tag assigned to this object in string format
std::string myDefinition
text with a definition of attribute
bool hasAttrRange() const
return true if Attr correspond to an element that only accept a range of values
bool isSVCPermission() const
return true if atribute is a VehicleClass
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
static void fillJunctionModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
int myTagType
Attribute Type.
static const std::string FEATURE_LOADED
bool isString() const
return true if atribute is a string
bool isComplex() const
return true if atribute is complex
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Encapsulated SAX-Attributes.
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
int myAttributeProperty
Property of attribute.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
static void fillNetElements()
fill Net Elements
static void fillCommonPersonAttributes(SumoXMLTag currentTag)
fill common person attributes (used by person and personFlows)
SumoXMLTag myParentTag
parent tag
std::vector< std::string > myDiscreteValues
discrete values that can take this Attribute (by default empty)
bool canMaskXYZPositions() const
return true if tag correspond to an element that can mask the attributes "X", "Y" and "Z" position as...
static const size_t MAXNUMBEROFATTRIBUTES
max number of attributes allowed for every tag
int getNumberOfAttributes() const
get number of attributes
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
std::string getDescription() const
return a description of attribute
void setRange(const double minimum, const double maximum)
set range