Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/mesogui/GUIMEVehicleControl.h
169666 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 GUIMEVehicleControl.h
15
/// @author Jakob Erdmann
16
/// @date Okt 2012
17
///
18
// The class responsible for building and deletion of meso vehicles (gui-version)
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <vector>
24
#include <utils/foxtools/fxheader.h>
25
#include <utils/gui/globjects/GUIGlObject.h>
26
#include <mesosim/MEVehicleControl.h>
27
28
29
// ===========================================================================
30
// class definitions
31
// ===========================================================================
32
/**
33
* @class GUIMEVehicleControl
34
* @brief The class responsible for building and deletion of vehicles (gui-version)
35
*
36
* @see MEVehicleControl
37
*/
38
class GUIMEVehicleControl : public MEVehicleControl {
39
public:
40
/// @brief Constructor
41
GUIMEVehicleControl() ;
42
43
44
/// @brief Destructor
45
~GUIMEVehicleControl() ;
46
47
/// @name Vehicle creation
48
/// @{
49
50
/** @brief Builds a vehicle, increases the number of built vehicles
51
*
52
* Instead of a MEVehicle, a GUIMEVehicle is built
53
*
54
* @param[in] defs The parameter defining the vehicle
55
* @param[in] route The route of this vehicle
56
* @param[in] type The type of this vehicle
57
* @param[in] ignoreStopErrors whether invalid stops trigger a warning only
58
* @param[in] source whether we are just reading the route file or creating via trigger, traci, ...
59
* @return The built vehicle (GUIVehicle instance)
60
* @see MSVehicleControl::buildVehicle
61
*/
62
SUMOVehicle* buildVehicle(SUMOVehicleParameter* defs,
63
ConstMSRoutePtr route, MSVehicleType* type,
64
const bool ignoreStopErrors, const VehicleDefinitionSource source = VehicleDefinitionSource::ROUTEFILE,
65
bool addRouteStops = true) override;
66
/// @}
67
68
/** @brief Tries to insert the vehicle into the internal vehicle container
69
*
70
* Identical to the MSVehicleControl implementation except for locking.
71
*
72
* @param[in] id The id of the vehicle
73
* @param[in] v The vehicle
74
* @return Whether the vehicle could be inserted (no other vehicle with the same id was inserted before)
75
*/
76
bool addVehicle(const std::string& id, SUMOVehicle* v) override;
77
78
/** @brief Deletes the vehicle
79
*
80
* Identical to the MSVehicleControl implementation except for locking.
81
*
82
* @param[in] v The vehicle to delete
83
* @param[discard] Whether the vehicle is discard during loading (scale < 1)
84
*/
85
void deleteVehicle(SUMOVehicle* v, bool discard = false, bool wasKept = false) override;
86
87
/** @brief Returns the list of all known vehicles by gl-id
88
* @param[fill] into The list to fill with vehicle ids
89
* @todo Well, what about concurrent modifications?
90
*/
91
void insertVehicleIDs(std::vector<GUIGlID>& into);
92
93
/// @brief get current absolute and relative mean vehicle speed in the network
94
virtual std::pair<double, double> getVehicleMeanSpeeds() const override;
95
96
/** @brief Returns the number of halting vehicles
97
* @return The number of halting vehicles
98
*/
99
virtual int getHaltingVehicleNo() const override;
100
101
/// @brief lock access to vehicle removal/additions for thread synchronization
102
void secureVehicles() override;
103
104
/// @brief unlock access to vehicle removal/additions for thread synchronization
105
void releaseVehicles() override;
106
107
108
private:
109
/// The mutex used to avoid concurrent updates of the vehicle buffer
110
mutable FXMutex myLock;
111
112
113
private:
114
/// @brief invalidated copy constructor
115
GUIMEVehicleControl(const GUIMEVehicleControl& s);
116
117
/// @brief invalidated assignment operator
118
GUIMEVehicleControl& operator=(const GUIMEVehicleControl& s);
119
120
121
};
122
123