17 #ifndef GNEAttributeCarrier_h 18 #define GNEAttributeCarrier_h 121 void setRange(
const double minimum,
const double maximum);
342 void checkTagIntegrity()
const;
354 std::vector<AttributeProperties>::const_iterator begin()
const;
357 std::vector<AttributeProperties>::const_iterator end()
const;
360 int getNumberOfAttributes()
const;
378 bool isNetElement()
const;
381 bool isAdditional()
const;
384 bool isShape()
const;
390 bool isDemandElement()
const;
393 bool isStoppingPlace()
const;
396 bool isDetector()
const;
399 bool isVehicleType()
const;
402 bool isVehicle()
const;
405 bool isRoute()
const;
411 bool isPerson()
const;
414 bool isPersonPlan()
const;
417 bool isPersonTrip()
const;
426 bool isPersonStop()
const;
429 bool isDrawable()
const;
432 bool isSelectable()
const;
435 bool canBlockMovement()
const;
438 bool canBlockShape()
const;
441 bool canCloseShape()
const;
444 bool hasGEOPosition()
const;
447 bool hasGEOShape()
const;
450 bool hasParent()
const;
453 bool hasTagSynonym()
const;
456 bool hasDialog()
const;
459 bool hasMinimumNumberOfChildren()
const;
462 bool hasGenericParameters()
const;
465 bool isPlacedInRTree()
const;
468 bool canBeSortedManually()
const;
471 bool canBeReparent()
const;
474 bool canAutomaticSortChildren()
const;
477 bool canWriteChildrenSeparate()
const;
480 bool canMaskStartEndPos()
const;
483 bool canMaskXYZPositions()
const;
486 bool isAttributeDeprecated(
SumoXMLAttr attr)
const;
615 const std::string
getID()
const;
621 static std::vector<SumoXMLTag>
allowedTags(
bool onlyDrawables);
660 static T
parse(
const std::string&
string);
666 parse<T>(net, value);
678 static T
parse(
GNENet* net,
const std::string& value);
682 static std::string
parseIDs(
const std::vector<T>& ACs);
688 template <
typename T>
690 bool parsedOk =
true;
692 std::string defaultValue, parsedAttribute, warningMessage;
696 if (tagProperties.isAttributeDeprecated(attribute)) {
699 WRITE_WARNING(
"Attribute " +
toString(attribute) +
"' of " + tagProperties.getTagStr() +
" is deprecated and will not be loaded.");
705 if (objectID !=
"") {
706 warningMessage = tagProperties.getTagStr() +
" with ID '" + objectID +
"'";
708 warningMessage = tagProperties.getTagStr();
713 if (tagProperties.canBlockMovement()) {
715 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
717 if (!canParse<bool>(parsedAttribute)) {
720 return parse<T>(
"0");
723 return parse<T>(parsedAttribute);
726 throw ProcessError(
"Trying to parsing block movement attribute in an AC that cannot be moved");
734 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
736 if (!canParse<double>(parsedAttribute)) {
738 warningMessage +
" is invalid; Cannot be parsed to float; " + tagProperties.getTagStr() +
" cannot be created");
740 return parse<T>(
"0");
743 return parse<T>(parsedAttribute);
748 return parse<T>(
"0");
751 const auto& attrProperties = tagProperties.getAttributeProperties(attribute);
753 if (attrProperties.isNumerical() || attrProperties.isBool()) {
755 }
else if (attrProperties.isColor()) {
756 defaultValue =
"black";
757 }
else if (attrProperties.isposition()) {
758 defaultValue =
"0,0";
763 parsedAttribute = attrs.
get<std::string>(attribute, objectID.c_str(), parsedOk,
false);
765 if (!
checkParsedAttribute(tagProperties, attrProperties, attribute, defaultValue, parsedAttribute, warningMessage)) {
768 }
else if (tagProperties.canMaskXYZPositions() && (attribute ==
SUMO_ATTR_POSITION)) {
775 if (attrProperties.isWriteXMLOptional()) {
776 parsedAttribute = attrProperties.getDefaultValue();
778 WRITE_WARNING(
"Essential " + attrProperties.getDescription() +
" attribute '" +
toString(attribute) +
"' of " +
779 warningMessage +
" is missing; " + tagProperties.getTagStr() +
" cannot be created");
783 parsedAttribute = defaultValue;
787 return parse<T>(parsedAttribute);
857 std::string& defaultValue, std::string& parsedAttribute, std::string& warningMessage);
861 const AttributeProperties& attrProperties, std::string& parsedAttribute, std::string& warningMessage);
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
static const std::string FEATURE_APPROVED
feature has been approved but not changed (i.e. after being reguessed)
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
bool hasAttrRange() const
return true if Attr correspond to an element that only accept a range of values
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
static const TagProperties & getTagProperties(SumoXMLTag tag)
get Tag Properties
SumoXMLTag
Numbers representing SUMO-XML - element names.
const std::string & getAttrStr() const
get XML Attribute
GUIIcon myIcon
icon associated to this Tag
SumoXMLTag myParentTag
parent tag
bool isExtended() const
return true if atribute is extended
SumoXMLAttr getAttrSynonym() const
get tag synonym
GNEAttributeCarrier(const SumoXMLTag tag)
Constructor.
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
GUIIcon
An enumeration of icons used by the gui applications.
bool hasMutableDefaultValue() const
return true if attribute owns a mutable default value
static void fillVehicleElements()
fill vehicle elements
bool isCombinable() const
return true if atribute is combinable with other Attribute
std::string myDefaultValue
default value (by default empty)
the function-object for an editing operation (abstract base)
struct with the attribute Properties
bool isFilename() const
return true if atribute is a filename
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)
bool isPositive() const
return true if atribute is positive
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static void fillStopElements()
fill Stop elements
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.
bool isComplex() const
return true if atribute is complex
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
static void fillAdditionals()
fill Additionals
static std::vector< SumoXMLTag > allowedTagsByCategory(int tagPropertyCategory, bool onlyDrawables)
get tags of all editable element types using TagProperty Type (TAGTYPE_NETELEMENT, TAGTYPE_ADDITIONAL, etc.)
static void fillPersonStopElements()
fill PersonStop elements
FXIcon * getIcon() const
get FXIcon associated to this AC
~AttributeProperties()
destructor
A NBNetBuilder extended by visualisation and editing capabilities.
static void fillDemandElements()
fill Demand Elements
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
bool isNumerical() const
return true if atribute is numerical (int or float)
bool isSecuential() const
return true if atribute is sequential
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
SumoXMLAttr myAttrSynonym
Attribute written in XML (If is SUMO_ATTR_NOTHING), original Attribute will be written) ...
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool cannotBeZero() const
return true if atribute cannot be zero
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
bool hasStaticDefaultValue() const
return true if attribute owns a static default value
int getPositionListed() const
get position in list (used in frames for listing attributes with certain sort)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
SumoXMLTag myTag
Sumo XML Tag vinculated wit this tag Property.
bool isProbability() const
return true if atribute is a probability
bool isNonEditable() const
return true if atribute isn't editable
virtual void selectAttributeCarrier(bool changeFlag=true)=0
#define WRITE_WARNING(msg)
bool isInt() const
return true if atribute is an integer
std::string myAttrStr
string with the Attribute in text format (to avoid unnecesaries toStrings(...) calls) ...
static TagProperties dummyTagProperty
dummy TagProperty used for reference some elements (for Example, dummyEdge)
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
virtual bool drawUsingSelectColor() const =0
check if attribute carrier must be drawn using selecting color.
void setDiscreteValues(const std::vector< std::string > &discreteValues)
set discrete values
int myTagType
Attribute Type.
bool isList() const
return true if atribute is a list
bool isColor() const
return true if atribute is a color
static std::vector< SumoXMLTag > allowedTags(bool onlyDrawables)
get tags of all editable element types
static const size_t MAXNUMBEROFATTRIBUTES
max number of attributes allowed for every tag
the function-object for an editing operation (abstract base)
virtual ~GNEAttributeCarrier()
Destructor.
static void fillShapes()
fill Shapes
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
double myMaximumRange
maxium Range
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getMaximumRange() const
get maximum range
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
std::vector< std::string > myDiscreteValues
discrete values that can take this Attribute (by default empty)
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
const TagProperties & getTagPropertyParent() const
get reference to tagProperty parent
static const double INVALID_POSITION
invalid double position
bool isBool() const
return true if atribute is boolean
std::string getDescription() const
return a description of attribute
static void fillAttributeCarriers()
fill Attribute Carriers
static bool lanesConsecutives(const std::vector< GNELane *> &lanes)
check if lanes are consecutives
double getMinimumRange() const
get minimum range
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
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)
static void fillNetElements()
fill Net Elements
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
static void fillPersonElements()
fill Person Elements
SumoXMLAttr getAttr() const
get XML Attribute
AttrProperty
struct with the tag Properties
bool isWriteXMLOptional() const
return true if atribute is write XML optional
block movement of a graphic element
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
bool isUnique() const
return true if atribute is unique
bool isVClass() const
return true if atribute is a VehicleClass
void setTagPropertyParent(TagProperties *tagPropertyParent)
set tag property parent
bool isSVCPermission() const
return true if atribute is a VehicleClass
bool isEnablitable() const
return true if atribute is enablitable
TagProperties * myTagPropertyParent
pointer to tagProperty parent
const std::string getID() const
function to support debugging
AttributeProperties()
default constructor
virtual void setEnabledAttribute(const int enabledAttributes)=0
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
static void fillCommonPersonAttributes(SumoXMLTag currentTag)
fill common person attributes (used by person and personFlows)
static void fillLaneChangingModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
A road/street connecting two junctions (netedit-version)
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
bool isDiscrete() const
return true if atribute is discrete
bool isFloat() const
return true if atribute is a float
double myMinimumRange
minimun Range
static void fillCommonStopAttributes(SumoXMLTag currentTag)
fill stop person attributes (used by stops and personStps)
static bool canParse(GNENet *net, const std::string &value, bool report)
true if a value of type T can be parsed from string
int myTagProperty
Attribute properties.
static void fillCarFollowingModelAttributes(SumoXMLTag currentTag)
fill Car Following Model of Vehicle/Person Types
std::vector< AttributeProperties > myAttributeProperties
vector with the attribute values vinculated with this Tag
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
std::string myDefinition
text with a definition of attribute
struct with the attribute Properties
const std::vector< std::string > & getDiscreteValues() const
get discrete values
bool requiereUpdateGeometry() const
return true if atribute requieres a update geometry in setAttribute(...)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isString() const
return true if atribute is a string
static void fillJunctionModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
void setSynonym(const SumoXMLAttr synonym)
set synonim
bool hasAttrSynonym() const
return true if Attr correspond to an element that will be written in XML with another name ...
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
bool isSUMOTime() const
return true if atribute is a SUMOTime
static const std::string FEATURE_LOADED
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
const std::string & getDefaultValue() const
get default value
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
static void fillCommonVehicleAttributes(SumoXMLTag currentTag)
fill common vehicle attributes (used by vehicles, trips, routeFlows and flows)
std::vector< SumoXMLAttr > myDeprecatedAttributes
List with the deprecated Attributes.
const std::string & getDefinition() const
get default value
SumoXMLTag myTagSynonym
Tag written in XML (If is SUMO_TAG_NOTHING), original Tag name will be written)
static void fillCommonFlowAttributes(SumoXMLTag currentTag)
fill common flow attributes (used by flows, routeFlows and personFlows)
void setRange(const double minimum, const double maximum)
set range
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc.)
virtual void updateGeometry()=0
update pre-computed geometry information
static std::map< SumoXMLTag, TagProperties > myTagProperties
map with the tags properties
int myAttributeProperty
Property of attribute.
SumoXMLAttr myAttribute
XML Attribute.
std::string myTagStr
Sumo XML Tag vinculated wit this tag Property in String format.
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
bool isOptional() const
return true if atribute is optional