Eclipse SUMO - Simulation of Urban MObility
GNEDataInterval.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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A abstract class for data elements
19 /****************************************************************************/
20 #pragma once
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
29 
30 #include "GNEDataSet.h"
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNEDataSet;
37 class GNEGenericData;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
42 
48 
49 public:
55  GNEDataInterval(GNEDataSet* dataSetParent, const double begin, const double end);
56 
59 
61  void updateGenericDataIDs();
62 
64  void updateAttributeColors();
65 
68 
70  const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
71 
73  const std::string& getID() const;
74 
77 
79  void updateGeometry();
80 
83 
87  bool isDataIntervalValid() const;
88 
90  std::string getDataIntervalProblem() const;
91 
95 
98 
101 
103  void addGenericDataChild(GNEGenericData* genericData);
104 
106  void removeGenericDataChild(GNEGenericData* genericData);
107 
109  bool hasGenericDataChild(GNEGenericData* genericData) const;
110 
112  const std::vector<GNEGenericData*>& getGenericDataChildren() const;
113 
117  /* @brief method for getting the Attribute of an XML key
118  * @param[in] key The attribute key
119  * @return string with the value associated to key
120  */
121  std::string getAttribute(SumoXMLAttr key) const;
122 
123  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
124  * @param[in] key The attribute key
125  * @return double with the value associated to key
126  */
127  double getAttributeDouble(SumoXMLAttr key) const;
128 
134  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
135 
141  bool isValid(SumoXMLAttr key, const std::string& value);
142 
143  /* @brief method for enable attribute
144  * @param[in] key The attribute key
145  * @param[in] undoList The undoList on which to register changes
146  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
147  */
148  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
149 
150  /* @brief method for disable attribute
151  * @param[in] key The attribute key
152  * @param[in] undoList The undoList on which to register changes
153  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
154  */
155  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
156 
157  /* @brief method for check if the value for certain attribute is set
158  * @param[in] key The attribute key
159  */
160  bool isAttributeEnabled(SumoXMLAttr key) const;
161 
163  std::string getPopUpID() const;
164 
166  std::string getHierarchyName() const;
168 
170  const std::map<std::string, std::string>& getACParametersMap() const;
171 
172 protected:
175 
177  std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
178 
181 
183  double myBegin;
184 
186  double myEnd;
187 
189  std::vector<GNEGenericData*> myGenericDataChildren;
190 
191 private:
193  void setAttribute(SumoXMLAttr key, const std::string& value);
194 
196  void setEnabledAttribute(const int enabledAttributes);
197 
200 
203 };
204 
205 /****************************************************************************/
206 
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
void fixDataIntervalProblem()
fix data element problem (by default throw an exception, has to be reimplemented in children)
bool isAttributeEnabled(SumoXMLAttr key) const
double myBegin
begin interval
Position getPositionInView() const
Returns element position in view.
GNEDataInterval(GNEDataSet *dataSetParent, const double begin, const double end)
Constructor.
GNEDataSet * myDataSetParent
GNEDataSet parent to which this data interval belongs.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform data element changes
void removeGenericDataChild(GNEGenericData *genericData)
add generic data child
GNEDataInterval & operator=(const GNEDataInterval &)=delete
Invalidated assignment operator.
std::string getAttribute(SumoXMLAttr key) const
double getAttributeDouble(SumoXMLAttr key) const
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
bool isDataIntervalValid() const
GNEDataSet * getDataSetParent() const
Returns a pointer to GNEDataSet parent.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const std::string & getID() const
get ID
bool hasGenericDataChild(GNEGenericData *genericData) const
check if given generic data is child of this data interval
GNEDataSet::AttributeColors myAllAttributeColors
all attribute colors
const std::vector< GNEGenericData * > & getGenericDataChildren() const
get generic data children
double myEnd
end interval
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
const std::map< SumoXMLTag, GNEDataSet::AttributeColors > & getSpecificAttributeColors() const
specific attribute colors
void updateGenericDataIDs()
update generic data child IDs
~GNEDataInterval()
Destructor.
std::map< SumoXMLTag, GNEDataSet::AttributeColors > mySpecificAttributeColors
specific attribute colors
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
std::string getDataIntervalProblem() const
return a string with the current data element problem (by default empty, can be reimplemented in chil...
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNEDataInterval(const GNEDataInterval &)=delete
Invalidated copy constructor.
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
const GNEDataSet::AttributeColors & getAllAttributeColors() const
all attribute colors
std::vector< GNEGenericData * > myGenericDataChildren
vector with generic data children
void addGenericDataChild(GNEGenericData *genericData)
add generic data child
void updateGeometry()
update pre-computed geometry information
void updateAttributeColors()
update attribute colors deprecated
@bief attribute colors
Definition: GNEDataSet.h:46
An Element which don't belongs to GNENet but has influency in the simulation.
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36