Eclipse SUMO - Simulation of Urban MObility
GNEDataHandler.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 // Builds data objects for netedit
19 /****************************************************************************/
20 #pragma once
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #include <config.h>
27 
28 #include <fx.h>
29 #include <utils/geom/Position.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GNENet;
39 class GNEEdge;
40 class GNETAZElement;
41 class GNEEdgeData;
42 class GNEEdgeRelData;
43 class GNETAZRelData;
44 class GNEGenericData;
45 class GNEDataSet;
46 class GNEDataInterval;
47 class GNEDataSet;
48 class GNEUndoList;
49 class GNEViewNet;
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
54 
56 class GNEDataLoadDialog : protected FXDialogBox {
57 
58 public:
60  GNEDataLoadDialog(GNEViewNet* viewNet);
61 
64 
66  void increase();
67 
68 private:
71 
73  FXLabel* myLabel;
74 
76  int myCounter;
77 };
78 
79 
80 
84 public:
85 
88 
90  void insertElement(SumoXMLTag tag);
91 
93  void commitDataIntervalInsertion(GNEDataInterval* dataIntervalCreated);
94 
96  void commitGenericDataInsertion(GNEGenericData* dataElementCreated);
97 
99  void popElement();
100 
103 
106 
109 
112 
113  private:
115  std::vector<std::pair<SumoXMLTag, std::pair<GNEDataInterval*, GNEGenericData*> > > myInsertedElements;
116  };
117 
119  GNEDataHandler(const std::string& file, GNENet* net);
120 
122  ~GNEDataHandler();
123 
126 
132  void myStartElement(int element, const SUMOSAXAttributes& attrs);
133 
139  void myEndElement(int element);
140 
142 
147 
155  static bool buildData(GNENet* net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas);
156 
163  static GNEDataSet* buildDataSet(GNENet* net, bool allowUndoRedo, const std::string& dataSetID);
164 
173  static GNEDataInterval* buildDataInterval(GNENet* net, bool allowUndoRedo, GNEDataSet* dataSetParent,
174  const double begin, const double end);
175 
184  static GNEGenericData* buildEdgeData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent,
185  GNEEdge* edge, const std::map<std::string, std::string>& parameters);
186 
196  static GNEGenericData* buildEdgeRelationData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent,
197  GNEEdge* fromEdge, GNEEdge* toEdge, const std::map<std::string, std::string>& parameters);
198 
208  static GNEGenericData* buildTAZRelationData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent,
209  GNETAZElement* fromTAZ, GNETAZElement* toTAZ, const std::map<std::string, std::string>& parameters);
210 
211 protected:
217 
221  static bool parseAndBuildInterval(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas);
222 
226  static bool parseAndBuildEdgeData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas);
227 
231  static bool parseAndBuildEdgeRelationData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas);
232 
236  static bool parseAndBuildTAZRelationData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas);
237 
239 
240 private:
244  void parseParameter(const SUMOSAXAttributes& attrs);
245 
248 
250  /* GNEDataLoadDialog *myLoadDialog; */
251 
254 
256  GNEDataHandler(const GNEDataHandler& s) = delete;
257 
260 };
SumoXMLTag
Numbers representing SUMO-XML - element names.
Builds data objects for GNENet (busStops, chargingStations, detectors, etc..)
static bool parseAndBuildEdgeData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a edge data.
~GNEDataHandler()
Destructor.
static bool parseAndBuildTAZRelationData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a TAZ relation data.
HierarchyInsertedDatas myHierarchyInsertedGenericDatas
load dialog (currently disabled)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static bool buildData(GNENet *net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Build datas.
GNEDataHandler(const std::string &file, GNENet *net)
Constructor.
void myEndElement(int element)
Called when a closing tag occurs.
static GNEDataInterval * buildDataInterval(GNENet *net, bool allowUndoRedo, GNEDataSet *dataSetParent, const double begin, const double end)
Builds DataInterval.
static bool parseAndBuildEdgeRelationData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a edge relation data.
static GNEGenericData * buildTAZRelationData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNETAZElement *fromTAZ, GNETAZElement *toTAZ, const std::map< std::string, std::string > &parameters)
Builds TAZRelationData.
GNEDataHandler & operator=(const GNEDataHandler &s)=delete
invalidate assignment operator
static bool parseAndBuildInterval(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a interval.
static GNEGenericData * buildEdgeData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNEEdge *edge, const std::map< std::string, std::string > &parameters)
Builds edgeData.
GNENet * myNet
pointer to net
static GNEGenericData * buildEdgeRelationData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNEEdge *fromEdge, GNEEdge *toEdge, const std::map< std::string, std::string > &parameters)
Builds edgeRelationData.
void parseParameter(const SUMOSAXAttributes &attrs)
Parse parameter and insert it in the last created data.
GNEDataHandler(const GNEDataHandler &s)=delete
invalidate copy constructor
static GNEDataSet * buildDataSet(GNENet *net, bool allowUndoRedo, const std::string &dataSetID)
Builds DataSet.
An Element which don't belongs to GNENet but has influency in the simulation.
FXLabel * myLabel
label
int myCounter
counter
~GNEDataLoadDialog()
destructor
void increase()
increase counter
GNEDataLoadDialog(GNEViewNet *viewNet)
constructor
GNEViewNet * myViewNet
pointer to viewNet
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEEdgeData.h:37
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
An Element which don't belongs to GNENet but has influency in the simulation.
An Element which don't belongs to GNENet but has influency in the simulation.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZRelData.h:37
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.
Stack used to save the last inserted element.
void insertElement(SumoXMLTag tag)
insert new element (called only in function myStartElement)
GNEGenericData * getLastInsertedGenericData() const
return last generic data inserted
GNEDataInterval * retrieveParentDataInterval(SumoXMLTag expectedTag) const
retrieve parent generic data correspond to current status of myInsertedElements
void commitGenericDataInsertion(GNEGenericData *dataElementCreated)
commit element insertion (used to save last correct generic data element)
std::vector< std::pair< SumoXMLTag, std::pair< GNEDataInterval *, GNEGenericData * > > > myInsertedElements
vector used as stack
void commitDataIntervalInsertion(GNEDataInterval *dataIntervalCreated)
commit element insertion (used to save last correct data interval element)
void popElement()
pop last inserted element (used only in function myEndElement)
GNEGenericData * retrieveParentGenericData(SumoXMLTag expectedTag) const
retrieve parent generic data correspond to current status of myInsertedElements
GNEDataInterval * getLastInsertedDataInterval() const
return last generic data inserted