Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNEDemandElementFlow.h
185790 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 GNEDemandElementFlow.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jul 2023
17
///
18
// An auxiliar, asbtract class for flow elements (vehicles, person and containers)
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/geom/Position.h>
24
#include <utils/xml/SUMOXMLDefinitions.h>
25
#include <utils/vehicle/SUMOVehicleParameter.h>
26
27
// ===========================================================================
28
// class declaration
29
// ===========================================================================
30
31
class SUMOVehicleParameter;
32
class GNEDemandElement;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNEDemandElementFlow : public SUMOVehicleParameter {
39
40
protected:
41
/// @brief constructor
42
GNEDemandElementFlow(GNEDemandElement* flowElement);
43
44
/// @brief constructor with parameters
45
GNEDemandElementFlow(GNEDemandElement* flowElement, const SUMOVehicleParameter& vehicleParameters);
46
47
/// @brief destructor
48
~GNEDemandElementFlow();
49
50
/// @brief draw flow label
51
void drawFlowLabel(const Position& position, const double rotation, const double width,
52
const double length, const double exaggeration) const;
53
54
/// @brief inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
55
/// @{
56
/* @brief method for getting the Attribute of an XML key
57
* @param[in] key The attribute key
58
* @return string with the value associated to key
59
*/
60
std::string getFlowAttribute(const GNEDemandElement* flowElement, SumoXMLAttr key) const;
61
62
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
63
* @param[in] key The attribute key
64
* @return double with the value associated to key
65
*/
66
double getFlowAttributeDouble(SumoXMLAttr key) const;
67
68
/* @brief method for setting the attribute and letting the object perform demand element changes
69
* @param[in] key The attribute key
70
* @param[in] value The new value
71
* @param[in] undoList The undoList on which to register changes
72
* @param[in] net optionally the GNENet to inform about gui updates
73
*/
74
void setFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
75
76
/* @brief method for setting the attribute and letting the object perform demand element changes
77
* @param[in] key The attribute key
78
* @param[in] value The new value
79
* @param[in] undoList The undoList on which to register changes
80
*/
81
bool isValidFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value);
82
83
/* @brief method for enable attribute
84
* @param[in] key The attribute key
85
* @param[in] undoList The undoList on which to register changes
86
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
87
*/
88
void enableFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, GNEUndoList* undoList);
89
90
/* @brief method for disable attribute
91
* @param[in] key The attribute key
92
* @param[in] undoList The undoList on which to register changes
93
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
94
*/
95
void disableFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, GNEUndoList* undoList);
96
97
/* @brief method for check if the value for certain attribute is set
98
* @param[in] key The attribute key
99
*/
100
bool isFlowAttributeEnabled(SumoXMLAttr key) const;
101
102
/// @brief method for setting the attribute and nothing else
103
void setFlowAttribute(GNEDemandElement* flowElement, SumoXMLAttr key, const std::string& value);
104
105
/// @brief toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
106
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value);
107
108
private:
109
/// @brief set flow default attributes
110
void setDefaultFlowAttributes(GNEDemandElement* flowElement);
111
112
/// @brief Invalidated copy constructor.
113
GNEDemandElementFlow(const GNEDemandElementFlow&) = delete;
114
115
/// @brief Invalidated assignment operator.
116
GNEDemandElementFlow& operator=(const GNEDemandElementFlow&) = delete;
117
};
118
119