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-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 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 
35 class GNENet;
36 class GNEDataInterval;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
43 
44 public:
47 
48  public:
51 
53  void updateValues(const std::string& attribute, const double value);
54 
56  void updateAllValues(const AttributeColors& attributeColors);
57 
59  double getMinValue(const std::string& attribute) const;
60 
62  double getMaxValue(const std::string& attribute) const;
63 
65  void clear();
66 
67  private:
69  std::map<std::string, std::pair<double, double> > myMinMaxValue;
70 
73  };
74 
78  GNEDataSet(GNENet* net, const std::string dataSetID);
79 
81  ~GNEDataSet();
82 
84  const std::string& getID() const;
85 
88 
90  void setDataSetID(const std::string& newID);
91 
93  void updateAttributeColors();
94 
97 
99  const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
100 
102  void updateGeometry();
103 
105  Position getPositionInView() const;
106 
108  void writeDataSet(OutputDevice& device) const;
109 
112 
114  void addDataIntervalChild(GNEDataInterval* dataInterval);
115 
117  void removeDataIntervalChild(GNEDataInterval* dataInterval);
118 
120  bool dataIntervalChildrenExist(GNEDataInterval* dataInterval) const;
121 
123  void updateDataIntervalBegin(const double oldBegin);
124 
126  bool checkNewInterval(const double newBegin, const double newEnd);
127 
129  bool checkNewBeginEnd(const GNEDataInterval* dataInterval, const double newBegin, const double newEnd);
130 
132  GNEDataInterval* retrieveInterval(const double begin, const double end) const;
133 
135  const std::map<const double, GNEDataInterval*>& getDataIntervalChildren() const;
136 
138 
141  /* @brief method for getting the Attribute of an XML key
142  * @param[in] key The attribute key
143  * @return string with the value associated to key
144  */
145  std::string getAttribute(SumoXMLAttr key) const;
146 
147  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
148  * @param[in] key The attribute key
149  * @return double with the value associated to key
150  */
151  double getAttributeDouble(SumoXMLAttr key) const;
152 
158  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
159 
165  bool isValid(SumoXMLAttr key, const std::string& value);
166 
167  /* @brief method for enable attribute
168  * @param[in] key The attribute key
169  * @param[in] undoList The undoList on which to register changes
170  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
171  */
172  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
173 
174  /* @brief method for disable attribute
175  * @param[in] key The attribute key
176  * @param[in] undoList The undoList on which to register changes
177  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
178  */
179  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
180 
181  /* @brief method for check if the value for certain attribute is set
182  * @param[in] key The attribute key
183  */
184  bool isAttributeEnabled(SumoXMLAttr key) const;
185 
187  std::string getPopUpID() const;
188 
190  std::string getHierarchyName() const;
192 
194  const std::map<std::string, std::string>& getACParametersMap() const;
195 
196 protected:
198  std::string myDataSetID;
199 
201  std::map<const double, GNEDataInterval*> myDataIntervalChildren;
202 
205 
207  std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
208 
209 private:
211  void setAttribute(SumoXMLAttr key, const std::string& value);
212 
214  void setEnabledAttribute(const int enabledAttributes);
215 
217  static bool checkNewInterval(const std::map<const double, GNEDataInterval*>& dataIntervalMap, const double newBegin, const double newEnd);
218 
220  GNEDataSet(const GNEDataSet&) = delete;
221 
223  GNEDataSet& operator=(const GNEDataSet&) = delete;
224 };
225 
226 /****************************************************************************/
227 
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:46
std::map< std::string, std::pair< double, double > > myMinMaxValue
map with the minimum and maximum value
Definition: GNEDataSet.h:69
void updateAllValues(const AttributeColors &attributeColors)
update value for all attributes
Definition: GNEDataSet.cpp:69
double getMaxValue(const std::string &attribute) const
get maximum value
Definition: GNEDataSet.cpp:95
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:89
void clear()
clear AttributeColors
Definition: GNEDataSet.cpp:101
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:316
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEDataSet.cpp:328
Position getPositionInView() const
Returns element position in view.
Definition: GNEDataSet.cpp:182
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEDataSet.cpp:125
void writeDataSet(OutputDevice &device) const
write data set
Definition: GNEDataSet.cpp:188
std::string myDataSetID
dataSet ID
Definition: GNEDataSet.h:198
bool dataIntervalChildrenExist(GNEDataInterval *dataInterval) const
check if given data interval exist
Definition: GNEDataSet.cpp:238
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:299
std::map< const double, GNEDataInterval * > myDataIntervalChildren
map with dataIntervals children sorted by begin
Definition: GNEDataSet.h:201
const std::string & getID() const
get ID
Definition: GNEDataSet.cpp:119
void removeDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:223
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEDataSet.cpp:362
GNEDataInterval * retrieveInterval(const double begin, const double end) const
return interval
Definition: GNEDataSet.cpp:281
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEDataSet.cpp:368
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEDataSet.cpp:392
~GNEDataSet()
Destructor.
Definition: GNEDataSet.cpp:115
const GNEDataSet::AttributeColors & getAllAttributeColors() const
all attribute colors
Definition: GNEDataSet.cpp:164
void setDataSetID(const std::string &newID)
set new ID in dataSet
Definition: GNEDataSet.cpp:131
void updateAttributeColors()
update attribute colors deprecated
Definition: GNEDataSet.cpp:142
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:310
std::map< SumoXMLTag, GNEDataSet::AttributeColors > mySpecificAttributeColors
specific attribute colors
Definition: GNEDataSet.h:207
GNEDataSet(const GNEDataSet &)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEDataSet.cpp:356
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:268
GNEDataSet::AttributeColors myAllAttributeColors
all attribute colors
Definition: GNEDataSet.h:204
GNEDataSet & operator=(const GNEDataSet &)=delete
Invalidated assignment operator.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEDataSet.cpp:344
GNEDataSet(GNENet *net, const std::string dataSetID)
Constructor.
Definition: GNEDataSet.cpp:109
const std::map< SumoXMLTag, GNEDataSet::AttributeColors > & getSpecificAttributeColors() const
specific attribute colors
Definition: GNEDataSet.cpp:170
const std::map< const double, GNEDataInterval * > & getDataIntervalChildren() const
get data interval children
Definition: GNEDataSet.cpp:293
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:262
void updateGeometry()
update pre-computed geometry information
Definition: GNEDataSet.cpp:176
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEDataSet.cpp:350
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEDataSet.cpp:374
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:211
void updateDataIntervalBegin(const double oldBegin)
update data interval begin
Definition: GNEDataSet.cpp:248
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
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