Eclipse SUMO - Simulation of Urban MObility
GNEDataSet.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-2022 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 #include <config.h>
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNENet;
37 class GNEDataInterval;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
42 
44 
45 public:
48 
49  public:
52 
54  void updateValues(const std::string& attribute, const double value);
55 
57  void updateAllValues(const AttributeColors& attributeColors);
58 
60  bool exist(const std::string& attribute) const;
61 
63  double getMinValue(const std::string& attribute) const;
64 
66  double getMaxValue(const std::string& attribute) const;
67 
69  void clear();
70 
71  private:
73  std::map<std::string, std::pair<double, double> > myMinMaxValue;
74 
77  };
78 
82  GNEDataSet(GNENet* net, const std::string dataSetID);
83 
85  ~GNEDataSet();
86 
89 
91  const std::string& getID() const;
92 
95 
97  void updateAttributeColors();
98 
101 
103  const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
104 
106  void updateGeometry();
107 
109  Position getPositionInView() const;
110 
112  void writeDataSet(OutputDevice& device) const;
113 
116 
118  void addDataIntervalChild(GNEDataInterval* dataInterval);
119 
121  void removeDataIntervalChild(GNEDataInterval* dataInterval);
122 
124  bool dataIntervalChildrenExist(GNEDataInterval* dataInterval) const;
125 
127  void updateDataIntervalBegin(const double oldBegin);
128 
130  bool checkNewInterval(const double newBegin, const double newEnd);
131 
133  bool checkNewBeginEnd(const GNEDataInterval* dataInterval, const double newBegin, const double newEnd);
134 
136  GNEDataInterval* retrieveInterval(const double begin, const double end) const;
137 
139  const std::map<const double, GNEDataInterval*>& getDataIntervalChildren() const;
140 
142 
145  /* @brief method for getting the Attribute of an XML key
146  * @param[in] key The attribute key
147  * @return string with the value associated to key
148  */
149  std::string getAttribute(SumoXMLAttr key) const;
150 
151  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
152  * @param[in] key The attribute key
153  * @return double with the value associated to key
154  */
155  double getAttributeDouble(SumoXMLAttr key) const;
156 
162  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
163 
169  bool isValid(SumoXMLAttr key, const std::string& value);
170 
171  /* @brief method for enable attribute
172  * @param[in] key The attribute key
173  * @param[in] undoList The undoList on which to register changes
174  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
175  */
176  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
177 
178  /* @brief method for disable attribute
179  * @param[in] key The attribute key
180  * @param[in] undoList The undoList on which to register changes
181  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
182  */
183  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
184 
185  /* @brief method for check if the value for certain attribute is set
186  * @param[in] key The attribute key
187  */
188  bool isAttributeEnabled(SumoXMLAttr key) const;
189 
190  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
191  * @param[in] key The attribute key
192  */
193  bool isAttributeComputed(SumoXMLAttr key) const;
194 
196  std::string getPopUpID() const;
197 
199  std::string getHierarchyName() const;
201 
203  const std::map<std::string, std::string>& getACParametersMap() const;
204 
205 protected:
207  std::string myDataSetID;
208 
210  std::map<const double, GNEDataInterval*> myDataIntervalChildren;
211 
214 
216  std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
217 
218 private:
220  void setAttribute(SumoXMLAttr key, const std::string& value);
221 
223  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
224 
226  static bool checkNewInterval(const std::map<const double, GNEDataInterval*>& dataIntervalMap, const double newBegin, const double newEnd);
227 
229  GNEDataSet(const GNEDataSet&) = delete;
230 
232  GNEDataSet& operator=(const GNEDataSet&) = delete;
233 };
234 
235 /****************************************************************************/
236 
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
@bief attribute colors
Definition: GNEDataSet.h:47
std::map< std::string, std::pair< double, double > > myMinMaxValue
map with the minimum and maximum value
Definition: GNEDataSet.h:73
void updateAllValues(const AttributeColors &attributeColors)
update value for all attributes
Definition: GNEDataSet.cpp:69
bool exist(const std::string &attribute) const
check if given attribute exist (needed for non-double attributes)
Definition: GNEDataSet.cpp:89
double getMaxValue(const std::string &attribute) const
get maximum value
Definition: GNEDataSet.cpp:101
AttributeColors & operator=(const AttributeColors &)=delete
Invalidated assignment operator.
AttributeColors()
default constructor
Definition: GNEDataSet.cpp:46
double getMinValue(const std::string &attribute) const
get minimum value
Definition: GNEDataSet.cpp:95
void clear()
clear AttributeColors
Definition: GNEDataSet.cpp:107
void updateValues(const std::string &attribute, const double value)
update value for an specific attribute
Definition: GNEDataSet.cpp:51
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform data element changes
Definition: GNEDataSet.cpp:321
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEDataSet.cpp:333
Position getPositionInView() const
Returns element position in view.
Definition: GNEDataSet.cpp:183
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEDataSet.cpp:137
void writeDataSet(OutputDevice &device) const
write data set
Definition: GNEDataSet.cpp:189
std::string myDataSetID
dataSet ID
Definition: GNEDataSet.h:207
bool dataIntervalChildrenExist(GNEDataInterval *dataInterval) const
check if given data interval exist
Definition: GNEDataSet.cpp:243
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:304
std::map< const double, GNEDataInterval * > myDataIntervalChildren
map with dataIntervals children sorted by begin
Definition: GNEDataSet.h:210
const std::string & getID() const
get ID
Definition: GNEDataSet.cpp:131
void removeDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:226
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:366
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEDataSet.cpp:372
GNEDataInterval * retrieveInterval(const double begin, const double end) const
return interval
Definition: GNEDataSet.cpp:286
GNEHierarchicalElement * getHierarchicalElement()
get GNEHierarchicalElement associated with this AttributeCarrier
Definition: GNEDataSet.cpp:125
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEDataSet.cpp:378
~GNEDataSet()
Destructor.
Definition: GNEDataSet.cpp:121
const GNEDataSet::AttributeColors & getAllAttributeColors() const
all attribute colors
Definition: GNEDataSet.cpp:165
void updateAttributeColors()
update attribute colors deprecated
Definition: GNEDataSet.cpp:143
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:315
std::map< SumoXMLTag, GNEDataSet::AttributeColors > mySpecificAttributeColors
specific attribute colors
Definition: GNEDataSet.h:216
GNEDataSet(const GNEDataSet &)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:360
bool checkNewBeginEnd(const GNEDataInterval *dataInterval, const double newBegin, const double newEnd)
check if new begin or end for given GNEDataInterval is given
Definition: GNEDataSet.cpp:273
GNEDataSet::AttributeColors myAllAttributeColors
all attribute colors
Definition: GNEDataSet.h:213
GNEDataSet & operator=(const GNEDataSet &)=delete
Invalidated assignment operator.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEDataSet.cpp:348
GNEDataSet(GNENet *net, const std::string dataSetID)
Constructor.
Definition: GNEDataSet.cpp:115
const std::map< SumoXMLTag, GNEDataSet::AttributeColors > & getSpecificAttributeColors() const
specific attribute colors
Definition: GNEDataSet.cpp:171
const std::map< const double, GNEDataInterval * > & getDataIntervalChildren() const
get data interval children
Definition: GNEDataSet.cpp:298
bool checkNewInterval(const double newBegin, const double newEnd)
check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet
Definition: GNEDataSet.cpp:267
void updateGeometry()
update pre-computed geometry information
Definition: GNEDataSet.cpp:177
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEDataSet.cpp:354
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEDataSet.cpp:384
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEDataSet.cpp:406
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:212
void updateDataIntervalBegin(const double oldBegin)
update data interval begin
Definition: GNEDataSet.cpp:253
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37