Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/GNEGeneralHandler.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNEGeneralHandler.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Sep 2021
17
///
18
// General element handler for netedit
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
28
#include <utils/handlers/GeneralHandler.h>
29
#include <netedit/elements/additional/GNEAdditionalHandler.h>
30
#include <netedit/elements/demand/GNERouteHandler.h>
31
#include <netedit/elements/data/GNEMeanDataHandler.h>
32
33
// ===========================================================================
34
// class declarations
35
// ===========================================================================
36
class GNENet;
37
38
// ===========================================================================
39
// class definitions
40
// ===========================================================================
41
42
class GNEGeneralHandler : public GeneralHandler {
43
44
public:
45
/**@brief Constructor
46
* @param[in] net GNENet
47
* @param[in] file Name of the parsed file
48
* @param[in] allowUndoRedo enable or disable undoRedo
49
*/
50
GNEGeneralHandler(GNENet* net, const std::string& file, const bool allowUndoRedo);
51
52
/// @brief Destructor
53
~GNEGeneralHandler();
54
55
/// @brief force overwritte elements (used if we're reloading elements)
56
void forceOverwriteElements();
57
58
/// @brief run post parser tasks
59
bool postParserTasks();
60
61
/// @brief get flag for check if a element wasn't created
62
bool isErrorCreatingElement() const;
63
64
/// @brief check if the parser file is a additional file
65
bool isAdditionalFile() const;
66
67
/// @brief check if the parser file is a route file
68
bool isRouteFile() const;
69
70
/// @brief check if the parser file is a meanData file
71
bool isMeanDataFile() const;
72
73
private:
74
/// @brief tagType
75
struct TagType {
76
77
enum class Type {
78
NONE,
79
NETWORK,
80
ADDITIONAL,
81
DEMAND,
82
DATA,
83
MEANDATA,
84
};
85
86
/// @brief constructor
87
TagType(SumoXMLTag tag, Type type);
88
89
/// @brief is network element
90
bool isNetwork() const;
91
92
/// @brief is network element
93
bool isAdditional() const;
94
95
/// @brief is network element
96
bool isDemand() const;
97
98
/// @brief is network element
99
bool isData() const;
100
101
/// @brief is network element
102
bool isMeanData() const;
103
104
/// @brief tag related with this TagType
105
const SumoXMLTag tag;
106
107
private:
108
/// @brief tag type
109
const Type myType;
110
};
111
112
/// @brief queue with the inserted tags
113
std::list<TagType> myQueue;
114
115
/// @brief additional handler
116
GNEAdditionalHandler myAdditionalHandler;
117
118
/// @brief demand handler
119
GNERouteHandler myDemandHandler;
120
121
/// @brief meanData handler
122
GNEMeanDataHandler myMeanDataHandler;
123
124
/// @brief flag for set file type
125
TagType::Type fileType = TagType::Type::NONE;
126
127
/// @brief start element
128
void beginTag(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
129
130
/// @brief end element
131
void endTag();
132
133
/// @brief invalidate copy constructor
134
GNEGeneralHandler(const GNEGeneralHandler& s) = delete;
135
136
/// @brief invalidate assignment operator
137
GNEGeneralHandler& operator=(const GNEGeneralHandler& s) = delete;
138
};
139
140
/****************************************************************************/
141
142