SUMO - Simulation of Urban MObility
GNEAttributeCarrier.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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Abstract Base class for gui objects which carry attributes
16 /****************************************************************************/
17 #ifndef GNEAttributeCarrier_h
18 #define GNEAttributeCarrier_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <fx.h>
27 #include <string>
28 #include <vector>
29 #include <map>
35 #include <utils/common/RGBColor.h>
37 #include <utils/common/ToString.h>
40 
41 #include "GNEReferenceCounter.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class GNENet;
48 class GNEEdge;
49 class GNELane;
50 class GNEUndoList;
51 class GUIGlObject;
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
64  friend class GNEChange_Attribute;
65 
66 public:
68  enum AttrProperty {
69  ATTRPROPERTY_INT = 1 << 0, // Attribute is an integer (Including Zero)
70  ATTRPROPERTY_FLOAT = 1 << 1, // Attribute is a float
71  ATTRPROPERTY_BOOL = 1 << 2, // Attribute is boolean (0/1, true/false)
72  ATTRPROPERTY_STRING = 1 << 3, // Attribute is a string
73  ATTRPROPERTY_POSITION = 1 << 4, // Attribute is a position defined by doubles (x,y or x,y,z)
74  ATTRPROPERTY_COLOR = 1 << 5, // Attribute is a color defined by a specifically word (Red, green) or by a special format (XXX,YYY,ZZZ)
75  ATTRPROPERTY_VCLASS = 1 << 6, // Attribute is a VClass (passenger, bus, motorcicle...)
76  ATTRPROPERTY_POSITIVE = 1 << 7, // Attribute is positive (Including Zero)
77  ATTRPROPERTY_NOTZERO = 1 << 8, // Attribute cannot be 0 (only for numerical attributes)
78  ATTRPROPERTY_UNIQUE = 1 << 9, // Attribute is unique (cannot be edited in a selection of similar elements (ID, Position...)
79  ATTRPROPERTY_FILENAME = 1 << 10, // Attribute is a filename (string that cannot contains certain characters)
80  ATTRPROPERTY_NONEDITABLE = 1 << 11, // Attribute is non editable (index of a lane)
81  ATTRPROPERTY_DISCRETE = 1 << 12, // Attribute is discrete (only certain values are allowed)
82  ATTRPROPERTY_PROBABILITY = 1 << 13, // Attribute is probability (only allowed values between 0 and 1, including both)
83  ATTRPROPERTY_TIME = 1 << 14, // Attribute is a Time (float positive)
84  ATTRPROPERTY_ANGLE = 1 << 15, // Attribute is an angle (only takes values between 0 and 360, including both, another value will be automatically reduced
85  ATTRPROPERTY_LIST = 1 << 16, // Attribute is a list of other elements separated by spaces
86  ATTRPROPERTY_OPTIONAL = 1 << 17, // Attribute is optional
87  ATTRPROPERTY_DEFAULTVALUE = 1 << 18, // Attribute owns a default value
88  ATTRPROPERTY_COMBINABLE = 1 << 19, // Attribute is combinable with other Attribute
89  ATTRPROPERTY_SYNONYM = 1 << 20, // Element will be written with a different name in der XML
90  };
91 
94  public:
97 
99  AttributeValues(int attributeProperty, int positionListed, const std::string& definition, const std::string& defaultValue, const std::vector<std::string>& discreteValues, SumoXMLAttr synonym);
100 
102  int getPositionListed() const;
103 
105  const std::string& getDefinition() const;
106 
108  const std::string& getDefaultValue() const;
109 
111  std::string getDescription() const;
112 
114  const std::vector<std::string>& getDiscreteValues() const;
115 
117  SumoXMLAttr getAttrSynonym() const;
118 
120  bool hasDefaultValue() const;
121 
123  bool hasAttrSynonym() const;
124 
126  bool isInt() const;
127 
129  bool isFloat() const;
130 
132  bool isBool() const;
133 
135  bool isString() const;
136 
138  bool isProbability() const;
139 
141  bool isNumerical() const;
142 
144  bool isTime() const;
145 
147  bool isPositive() const;
148 
150  bool isntZero() const;
151 
153  bool isColor() const;
154 
156  bool isFilename() const;
157 
159  bool isVClass() const;
160 
162  bool isSVCPermission() const;
163 
165  bool isList() const;
166 
168  bool isUnique() const;
169 
171  bool isOptional() const;
172 
174  bool isDiscrete() const;
175 
177  bool isCombinable() const;
178 
180  bool isNonEditable() const;
181 
182  private:
185 
188 
190  std::string myDefinition;
191 
193  std::string myDefaultValue;
194 
196  std::vector<std::string> myDiscreteValues;
197 
200  };
201 
202  enum TAGProperty {
203  TAGPROPERTY_NETELEMENT = 1 << 0, // Edges, Junctions, Lanes...
204  TAGPROPERTY_ADDITIONAL = 1 << 1, // Bus Stops, Charging Stations, Detectors...
205  TAGPROPERTY_SHAPE = 1 << 2, // POIs, Polygons
206  TAGPROPERTY_STOPPINGPLACE = 1 << 3, // StoppingPlaces (BusStops, ChargingStations...)
207  TAGPROPERTY_DETECTOR = 1 << 4, // Detectors (E1, E2...)
208  TAGPROPERTY_ROUTEELEMENT = 1 << 5, // VTypes, Vehicles, Flows...
209  TAGPROPERTY_DRAWABLE = 1 << 6, // Element can be drawed in view
210  TAGPROPERTY_BLOCKMOVEMENT = 1 << 7, // Element can block their movement
211  TAGPROPERTY_BLOCKSHAPE = 1 << 8, // Element can block their shape
212  TAGPROPERTY_CLOSESHAPE = 1 << 9, // Element can close their shape
213  TAGPROPERTY_GEOPOSITION = 1 << 10, // Element's position can be defined using a GEO position
214  TAGPROPERTY_GEOSHAPE = 1 << 11, // Element's shape acn be defined using a GEO Shape
215  TAGPROPERTY_DIALOG = 1 << 12, // Element can be edited using a dialog (GNECalibratorDialog, GNERerouterDialog...)
216  TAGPROPERTY_PARENT = 1 << 13, // Element will be writed in XML as child of another element (E3Entry -> E3Detector...)
217  TAGPROPERTY_MINIMUMCHILDS = 1 << 14, // Element will be only writed in XML if has a minimum number of childs
218  TAGPROPERTY_REPARENT = 1 << 15, // Element can be reparent
219  TAGPROPERTY_SYNONYM = 1 << 16, // Element will be written with a different name in der XML
220  TAGPROPERTY_AUTOMATICSORTING = 1 << 17, // Element sort automatic their Childs (used by Additionals)
221  TAGPROPERTY_SELECTABLE = 1 << 18, // Element is selectable
222  TAGPROPERTY_WRITECHILDSSEPARATE = 1 << 19, // Element writes their childs in a separated filename
223  };
224 
226  class TagValues {
227  public:
229  TagValues();
230 
232  TagValues(int tagProperty, int positionListed, GUIIcon icon, SumoXMLTag tagParent = SUMO_TAG_NOTHING, SumoXMLTag tagSynonym = SUMO_TAG_NOTHING);
233 
235  void addAttribute(SumoXMLAttr attr, int attributeProperty, const std::string& definition, const std::string& defaultValue, std::vector<std::string> discreteValues = std::vector<std::string>(), SumoXMLAttr synonym = SUMO_ATTR_NOTHING);
236 
238  void addAttribute(SumoXMLAttr attr, int attributeProperty, const std::string& definition, const std::string& defaultValue, SumoXMLAttr synonym);
239 
241  void addDeprecatedAttribute(SumoXMLAttr attr);
242 
244  const AttributeValues& getAttribute(SumoXMLAttr attr) const;
245 
247  std::map<SumoXMLAttr, AttributeValues>::const_iterator begin() const;
248 
250  std::map<SumoXMLAttr, AttributeValues>::const_iterator end() const;
251 
253  int getNumberOfAttributes() const;
254 
256  const std::string& getDefaultValue(SumoXMLAttr attr) const;
257 
259  GUIIcon getGUIIcon() const;
260 
262  int getPositionListed() const;
263 
265  SumoXMLTag getParentTag() const;
266 
268  SumoXMLTag getTagSynonym() const;
269 
271  bool hasAttribute(SumoXMLAttr attr) const;
272 
274  bool isNetElement() const;
275 
277  bool isAdditional() const;
278 
280  bool isShape() const;
281 
283  bool isStoppingPlace() const;
284 
286  bool isDetector() const;
287 
289  bool isDrawable() const;
290 
292  bool isSelectable() const;
293 
295  bool canBlockMovement() const;
296 
298  bool canBlockShape() const;
299 
301  bool canCloseShape() const;
302 
304  bool hasGEOPosition() const;
305 
307  bool hasGEOShape() const;
308 
310  bool hasParent() const;
311 
313  bool hasTagSynonym() const;
314 
316  bool hasDialog() const;
317 
319  bool hasMinimumNumberOfChilds() const;
320 
322  bool canBeReparent() const;
323 
325  bool canAutomaticSortChilds() const;
326 
328  bool canWriteChildsSeparate() const;
329 
331  bool isAttributeDeprecated(SumoXMLAttr attr) const;
332 
333  private:
336 
338  std::map<SumoXMLAttr, AttributeValues> myAttributeValues;
339 
342 
345 
348 
351 
353  std::vector<SumoXMLAttr> myDeprecatedAttributes;
354  };
355 
361 
363  virtual ~GNEAttributeCarrier() {};
364 
368  virtual void selectAttributeCarrier(bool changeFlag = true) = 0;
369 
371  virtual void unselectAttributeCarrier(bool changeFlag = true) = 0;
372 
374  virtual bool isAttributeCarrierSelected() const = 0;
375 
376  /* @brief method for getting the Attribute of an XML key
377  * @param[in] key The attribute key
378  * @return string with the value associated to key
379  */
380  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
381 
382  /* @brief method for setting the attribute and letting the object perform additional changes
383  * @param[in] key The attribute key
384  * @param[in] value The new value
385  * @param[in] undoList The undoList on which to register changes
386  * @param[in] net optionally the GNENet to inform about gui updates
387  */
388  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
389 
390  /* @brief method for setting the attribute and letting the object perform additional changes
391  * @param[in] key The attribute key
392  * @param[in] value The new value
393  * @param[in] undoList The undoList on which to register changes
394  */
395  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
396 
398  virtual std::string getPopUpID() const = 0;
399 
401  virtual std::string getHierarchyName() const = 0;
403 
407  static const std::string FEATURE_LOADED;
408 
410  static const std::string FEATURE_GUESSED;
411 
413  static const std::string FEATURE_MODIFIED;
414 
416  static const std::string FEATURE_APPROVED;
418 
420  virtual std::string getAttributeForSelection(SumoXMLAttr key) const;
421 
423  SumoXMLTag getTag() const;
424 
426  FXIcon* getIcon() const;
427 
429  const std::string getID() const;
430 
432  static const TagValues& getTagProperties(SumoXMLTag tag);
433 
435  static std::vector<SumoXMLTag> allowedTags(bool onlyDrawables);
436 
438  static std::vector<SumoXMLTag> allowedNetElementsTags(bool onlyDrawables);
439 
441  static std::vector<SumoXMLTag> allowedAdditionalTags(bool onlyDrawables);
442 
444  static std::vector<SumoXMLTag> allowedShapeTags(bool onlyDrawables);
445 
447  static int getHigherNumberOfAttributes();
448 
451 
453  virtual bool addGenericParameter(const std::string& key, const std::string& value) = 0;
454 
456  virtual bool removeGenericParameter(const std::string& key) = 0;
457 
459  virtual bool updateGenericParameter(const std::string& oldKey, const std::string& newKey) = 0;
460 
462  virtual bool updateGenericParameterValue(const std::string& key, const std::string& newValue) = 0;
463 
465  virtual std::string getGenericParametersStr() const = 0;
466 
468  virtual std::vector<std::pair<std::string, std::string> > getGenericParameters() const = 0;
469 
471  virtual void setGenericParametersStr(const std::string& value) = 0;
472 
474 
476  static bool isGenericParametersValid(const std::string& value);
477 
479  template<typename T>
480  static bool canParse(const std::string& string) {
481  try {
482  parse<T>(string);
483  } catch (NumberFormatException&) {
484  return false;
485  } catch (EmptyData&) {
486  return false;
487  } catch (BoolFormatException&) {
488  return false;
489  }
490  return true;
491  }
492 
494  template<typename T>
495  static T parse(const std::string& string);
496 
498  template<typename T>
499  static bool canParse(GNENet* net, const std::string& value, bool report) {
500  try {
501  parse<T>(net, value);
502  } catch (FormatException& exception) {
503  if (report) {
504  WRITE_WARNING(exception.what())
505  }
506  return false;
507  }
508  return true;
509  }
510 
512  template<typename T>
513  static T parse(GNENet* net, const std::string& value);
514 
516  template<typename T>
517  static std::string parseIDs(const std::vector<T>& ACs);
518 
520  static bool parseStringToANDBool(const std::string& string);
521 
523  static const double INVALID_POSITION;
524 
526  template <typename T>
527  static T parseAttributeFromXML(const SUMOSAXAttributes& attrs, const std::string& objectID, const SumoXMLTag tag, const SumoXMLAttr attribute, bool& abort) {
528  bool parsedOk = true;
529  // obtain tag properties
530  const auto& tagProperties = getTagProperties(tag);
531  // first check if attribute is deprecated
532  if (tagProperties.isAttributeDeprecated(attribute)) {
533  // show warning if deprecateda ttribute is in the SUMOSAXAttributes
534  if (attrs.hasAttribute(attribute)) {
535  WRITE_WARNING("Attribute " + toString(attribute) + "' of " + toString(tag) + " is deprecated and will not be loaded.");
536  }
537  return parse<T>("");
538  }
539  std::string defaultValue, parsedAttribute;
540  // obtain attribute properties (Only for improving efficiency)
541  const auto& attrProperties = tagProperties.getAttribute(attribute);
542  // set additionalOfWarningMessage
543  std::string additionalOfWarningMessage;
544  if (objectID != "") {
545  additionalOfWarningMessage = toString(tag) + " with ID '" + objectID + "'";
546  } else {
547  additionalOfWarningMessage = toString(tag);
548  }
549  // set a special default value for numerical and boolean attributes (To avoid errors parsing)
550  if (attrProperties.isNumerical() || attrProperties.isBool()) {
551  defaultValue = "0";
552  }
553  // first check that attribute exists in XML
554  if (attrs.hasAttribute(attribute)) {
555  // First check if attribute can be parsed to string
556  parsedAttribute = attrs.get<std::string>(attribute, objectID.c_str(), parsedOk, false);
557  // check that sucesfully parsed attribute can be converted to type T
558  if (parsedOk && !canParse<T>(parsedAttribute)) {
559  parsedOk = false;
560  // only set default value if this isn't a SVCPermission
561  if (!attrProperties.isVClass()) {
562  parsedAttribute = defaultValue;
563  }
564  }
565  // declare a string for details about error formats
566  std::string errorFormat;
567  // set extra check for ID Values
568  if (attribute == SUMO_ATTR_ID) {
569  if (parsedAttribute.empty()) {
570  errorFormat = "ID cannot be empty; ";
571  parsedOk = false;
572  } else if (SUMOXMLDefinitions::isValidNetID(parsedAttribute) == false) {
573  errorFormat = "'" + parsedAttribute + "' contains invalid characters; ";
574  parsedOk = false;
575  }
576  }
577  // Set extra checks for int values
578  if (attrProperties.isInt()) {
579  if (canParse<int>(parsedAttribute)) {
580  // obtain int value
581  int parsedIntAttribute = parse<int>(parsedAttribute);
582  // check if attribute can be negative or zero
583  if (attrProperties.isPositive() && (parsedIntAttribute < 0)) {
584  errorFormat = "Cannot be negative; ";
585  parsedOk = false;
586  } else if (attrProperties.isntZero() && (parsedIntAttribute == 0)) {
587  errorFormat = "Cannot be zero; ";
588  parsedOk = false;
589  }
590  } else if (canParse<double>(parsedAttribute)) {
591  errorFormat = "Float cannot be reinterpreted as int; ";
592  parsedOk = false;
593  } else {
594  errorFormat = "Cannot be parsed to int; ";
595  parsedOk = false;
596  }
597  }
598  // Set extra checks for float(double) values
599  if (attrProperties.isFloat()) {
600  if (canParse<double>(parsedAttribute)) {
601  // obtain double value
602  double parsedDoubleAttribute = parse<double>(parsedAttribute);
603  //check if can be negative and Zero
604  if (attrProperties.isPositive() && (parsedDoubleAttribute < 0)) {
605  errorFormat = "Cannot be negative; ";
606  parsedOk = false;
607  } else if (attrProperties.isntZero() && (parsedDoubleAttribute == 0)) {
608  errorFormat = "Cannot be zero; ";
609  parsedOk = false;
610  }
611  } else {
612  errorFormat = "Cannot be parsed to float; ";
613  parsedOk = false;
614  }
615  }
616  // set extra check for time(double) values
617  if (attrProperties.isTime()) {
618  if (canParse<double>(parsedAttribute)) {
619  // parse to SUMO Real and check if is negative
620  if (parse<double>(parsedAttribute) < 0) {
621  errorFormat = "Time cannot be negative; ";
622  parsedOk = false;
623  }
624  } else {
625  errorFormat = "Cannot be parsed to time; ";
626  parsedOk = false;
627  }
628  }
629  // set extra check for probability values
630  if (attrProperties.isProbability()) {
631  if (canParse<double>(parsedAttribute)) {
632  // parse to SUMO Real and check if is negative
633  if (parse<double>(parsedAttribute) < 0) {
634  errorFormat = "Probability cannot be smaller than 0; ";
635  parsedOk = false;
636  } else if (parse<double>(parsedAttribute) > 1) {
637  errorFormat = "Probability cannot be greather than 1; ";
638  parsedOk = false;
639  }
640  } else {
641  errorFormat = "Cannot be parsed to probability; ";
642  parsedOk = false;
643  }
644  }
645  // set extra check for discrete values
646  if (attrProperties.isDiscrete()) {
647  // search value in the list of discretes values of attribute properties
648  auto finder = std::find(attrProperties.getDiscreteValues().begin(), attrProperties.getDiscreteValues().end(), parsedAttribute);
649  // check if attribute is valid
650  if (finder == attrProperties.getDiscreteValues().end()) {
651  errorFormat = "value is not within the set of allowed values for attribute '" + toString(attribute) + "'";
652  parsedOk = false;
653  }
654  }
655  // set extra check for color values
656  if (attrProperties.isColor() && !canParse<RGBColor>(parsedAttribute)) {
657  errorFormat = "Invalid RGB format or named color; ";
658  parsedOk = false;
659  }
660  // set extra check for filename values
661  if (attrProperties.isFilename()) {
662  if (SUMOXMLDefinitions::isValidFilename(parsedAttribute) == false) {
663  errorFormat = "Filename contains invalid characters; ";
664  parsedOk = false;
665  } else if (parsedAttribute.empty()) {
666  errorFormat = "Filename cannot be empty; ";
667  parsedOk = false;
668  }
669  }
670  // set extra check for name values
671  if ((attribute == SUMO_ATTR_NAME) && !SUMOXMLDefinitions::isValidAttribute(parsedAttribute)) {
672  errorFormat = "name contains invalid characters; ";
673  parsedOk = false;
674  }
675  // set extra check for SVCPermissions values
676  if (attrProperties.isVClass()) {
677  if (!canParseVehicleClasses(parsedAttribute)) {
678  errorFormat = "List of VClasses isn't valid; ";
679  parsedAttribute = defaultValue;
680  parsedOk = false;
681  }
682  }
683  // set extra check for Vehicle Classes
684  if ((!parsedOk) && (attribute == SUMO_ATTR_VCLASS)) {
685  errorFormat = "Is not a part of defined set of Vehicle Classes; ";
686  }
687  // set extra check for Vehicle Classes
688  if ((!parsedOk) && (attribute == SUMO_ATTR_GUISHAPE)) {
689  errorFormat = "Is not a part of defined set of Gui Vehicle Shapes; ";
690  }
691  // set extra check for RouteProbes
692  if ((attribute == SUMO_ATTR_ROUTEPROBE) && !SUMOXMLDefinitions::isValidNetID(parsedAttribute)) {
693  errorFormat = "RouteProbe ID contains invalid characters; ";
694  parsedOk = false;
695  }
696  // set extra check for list of edges
697  if ((attribute == SUMO_ATTR_EDGES) && parsedAttribute.empty()) {
698  errorFormat = "List of edges cannot be empty; ";
699  parsedOk = false;
700  }
701  // set extra check for list of lanes
702  if ((attribute == SUMO_ATTR_LANES) && parsedAttribute.empty()) {
703  errorFormat = "List of lanes cannot be empty; ";
704  parsedOk = false;
705  }
706  // If attribute has an invalid format
707  if (!parsedOk) {
708  // if attribute is optional and has a default value, obtain it as string. In other case, abort.
709  if (attrProperties.isOptional() && attrProperties.hasDefaultValue()) {
710  parsedAttribute = attrProperties.getDefaultValue();
711  } else {
712  WRITE_WARNING("Format of essential " + attrProperties.getDescription() + " attribute '" + toString(attribute) + "' of " +
713  additionalOfWarningMessage + " is invalid; " + errorFormat + toString(tag) + " cannot be created");
714  // abort parsing (and creation) of element
715  abort = true;
716  // set default value (To avoid errors in parse<T>(parsedAttribute))
717  parsedAttribute = defaultValue;
718  }
719  }
720  } else {
721  // if attribute is optional and has a default value, obtain it. In other case, abort.
722  if (attrProperties.isOptional() && attrProperties.hasDefaultValue()) {
723  parsedAttribute = attrProperties.getDefaultValue();
724  } else {
725  WRITE_WARNING("Essential " + attrProperties.getDescription() + " attribute '" + toString(attribute) + "' of " +
726  additionalOfWarningMessage + " is missing; " + toString(tag) + " cannot be created");
727  // abort parsing (and creation) of element
728  abort = true;
729  // set default value (To avoid errors in parse<T>(parsedAttribute))
730  parsedAttribute = defaultValue;
731  }
732  }
733  // return parsed attribute
734  return parse<T>(parsedAttribute);
735  }
736 
738  static int getCircleResolution(const GUIVisualizationSettings& settings);
739 
740 protected:
743 
745  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
746 
748  virtual void mouseOverObject(const GUIVisualizationSettings& s) const = 0;
749 
751  static void fillAttributeCarriers();
752 
755 
757  static std::map<SumoXMLTag, TagValues> myAllowedTags;
758 
760  GNEAttributeCarrier(const GNEAttributeCarrier&) = delete;
761 
763  GNEAttributeCarrier& operator=(const GNEAttributeCarrier& src) = delete;
764 };
765 
766 #endif
767 
768 /****************************************************************************/
769 
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)
bool isSVCPermission() const
return true if atribute is a VehicleClass
bool isOptional() const
return true if atribute is optional
std::map< SumoXMLAttr, AttributeValues > myAttributeValues
map with the attribute values vinculated with this Tag
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
SumoXMLTag
Numbers representing SUMO-XML - element names.
static std::vector< SumoXMLTag > allowedAdditionalTags(bool onlyDrawables)
get all editable for tag additional elements
int myAttributeProperty
Property of attribute.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name) ...
const SumoXMLTag myTag
the xml tag to which this attribute carrier corresponds
virtual bool addGenericParameter(const std::string &key, const std::string &value)=0
add generic parameter
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
bool isTime() const
return true if atribute is time
virtual bool updateGenericParameterValue(const std::string &key, const std::string &newValue)=0
update value generic parameter
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:36
SumoXMLTag myTagSynonym
Tag written in XML (If is SUMO_TAG_NOTHING), original Tag name will be written)
bool isBool() const
return true if atribute is boolean
Stores the information about how to visualize structures.
static std::map< SumoXMLTag, TagValues > myAllowedTags
map with the tags values
std::string getDescription() const
return a description of attribute
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static int getHigherNumberOfAttributes()
return the number of attributes of the tag with the most highter number of attributes ...
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 hasAttrSynonym() const
return true if Attr correspond to an element that will be written in XML with another name ...
std::vector< std::string > myDiscreteValues
discrete values that can take this Attribute (by default empty)
FXIcon * getIcon() const
get FXIcon associated to this AC
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:80
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
bool isString() const
return true if atribute is a string
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
bool isVClass() const
return true if atribute is a VehicleClass
bool isList() const
return true if atribute is a list
virtual void selectAttributeCarrier(bool changeFlag=true)=0
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
virtual bool removeGenericParameter(const std::string &key)=0
remove generic parameter
bool isNumerical() const
return true if atribute is numerical (int or float)
static std::vector< SumoXMLTag > allowedTags(bool onlyDrawables)
get all editable for tag elements of all types
SumoXMLAttr getAttrSynonym() const
get tag synonym
SumoXMLAttr myAttrSynonym
Attribute written in XML (If is SUMO_ATTR_NOTHING), original Attribute will be written) ...
the function-object for an editing operation (abstract base)
std::string myDefinition
text with a definition of attribute
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
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.
static const double INVALID_POSITION
default value for invalid positions (used by POIs and Polygons)
static void fillAttributeCarriers()
fill Attribute Carriers
bool isPositive() const
return true if atribute is positive
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
static std::vector< SumoXMLTag > allowedShapeTags(bool onlyDrawables)
get all editable for tag shape elements
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
AttrProperty
struct with the tag Properties
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
invalid attribute
int getPositionListed() const
get position in list (used in frames for listing attributes with certain sort)
static bool parseStringToANDBool(const std::string &string)
parse a string of booleans (1 0 1 1....) using AND operation
const std::string getID() const
function to support debugging
const std::string & getDefaultValue() const
get default value
virtual ~GNEAttributeCarrier()
Destructor.
bool isColor() const
return true if atribute is a color
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
GNEAttributeCarrier(SumoXMLTag tag)
Constructor.
static bool canParse(GNENet *net, const std::string &value, bool report)
true if a value of type T can be parsed from string
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
std::string myDefaultValue
default value (by default empty)
const std::vector< std::string > & getDiscreteValues() const
get discrete values
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
static int getCircleResolution(const GUIVisualizationSettings &settings)
function to calculate circle resolution for all circles drawn in drawGL(...) functions ...
bool isCombinable() const
return true if atribute is combinable with other Attribute
std::vector< SumoXMLAttr > myDeprecatedAttributes
List with the deprecated Attributes.
bool isntZero() const
return true if atribute cannot be zero
bool isInt() const
return true if atribute is an integer
static const std::string FEATURE_LOADED
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
int myTagProperty
Property of attribute.
bool isFloat() const
return true if atribute is a float
bool isDiscrete() const
return true if atribute is discrete
static std::vector< SumoXMLTag > allowedNetElementsTags(bool onlyDrawables)
get all editable for tag net elements
static const TagValues & getTagProperties(SumoXMLTag tag)
get Tag Properties
bool isProbability() const
return true if atribute is a probability
bool isUnique() const
return true if atribute is unique
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc.)
const std::string & getDefinition() const
get default value
GUIIcon myIcon
icon associated to this Tag
struct with the attribute Properties
bool isNonEditable() const
return true if atribute isn&#39;t editable
struct with the attribute Properties
bool isFilename() const
return true if atribute is a filename
virtual bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)=0
update generic parameter
bool hasDefaultValue() const
return true if attribute owns a default value
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
SumoXMLTag getTag() const
get XML Tag assigned to this object
virtual void mouseOverObject(const GUIVisualizationSettings &s) const =0
method for check if mouse is over objects