Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
StdDefs.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2005-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/****************************************************************************/
21//
22/****************************************************************************/
23#pragma once
24#include <config.h>
25#include <string>
26#include <cmath>
27#include <limits>
28
29/* avoiding compiler warning unreferenced parameter */
30#define UNUSED_PARAMETER(x) ((void)(x))
31
32#ifdef _MSC_VER
33#if _MSC_VER < 1943
34#define FALLTHROUGH /* do nothing */
35#else
36#define FALLTHROUGH [[fallthrough]]
37#endif
38#elif __GNUC__ < 7
39#define FALLTHROUGH /* do nothing */
40#else
41#define FALLTHROUGH __attribute__((fallthrough))
42#endif
43
45#define SUMO_MAX_CONNECTIONS 256
46
47class RGBColor;
48
49/* -------------------------------------------------------------------------
50 * some constant defaults used by SUMO
51 * ----------------------------------------------------------------------- */
52const double SUMO_const_laneWidth = 3.2;
55const double SUMO_const_laneMarkWidth = 0.1;
60
62const double SUMO_const_haltingSpeed = (double) 0.1;
63
65const int INVALID_INT = std::numeric_limits<int>::max();
66
68const double INVALID_DOUBLE = std::numeric_limits<double>::max();
69
71typedef std::pair<int, double> MMVersion;
73
74/* -------------------------------------------------------------------------
75 * templates for mathematical functions missing in some c++-implementations
76 * ----------------------------------------------------------------------- */
77
78template<typename T>
79inline T
80MIN2(T a, T b) {
81 return a < b ? a : b;
82}
83
84template<typename T>
85inline T
86MAX2(T a, T b) {
87 return a > b ? a : b;
88}
89
90
91template<typename T>
92inline T
93MIN3(T a, T b, T c) {
94 return MIN2(c, a < b ? a : b);
95}
96
97
98template<typename T>
99inline T
100MAX3(T a, T b, T c) {
101 return MAX2(c, a > b ? a : b);
102}
103
104
105template<typename T>
106inline T
107MIN4(T a, T b, T c, T d) {
108 return MIN2(MIN2(a, b), MIN2(c, d));
109}
110
111
112template<typename T>
113inline T
114MAX4(T a, T b, T c, T d) {
115 return MAX2(MAX2(a, b), MAX2(c, d));
116}
117
118
120extern int gPrecision;
121extern int gPrecisionEmissions;
122extern int gPrecisionGeo; // for lon,lat
123extern int gPrecisionRandom; // for randomized values (i.e. speedFactor)
124extern bool gHumanReadableTime;
125extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
126extern bool gIgnoreUnknownVClass; // whether the unknown vehicle classes shall be ignored on loading (for upward compatibility)
127extern bool gLocaleInitialized; // whether the gettext locale for translating messages has already been loaded
128extern double gWeightsRandomFactor; // randomization for edge weights
129extern double gWeightsWalkOppositeFactor; // factor for walking against flow of traffic
130extern bool gRoutingPreferences; // whether routing preferences have been loaded
131
133extern std::string gLanguage;
134
136extern int GUIDesignHeight;
137
140
142extern bool gDebugFlag1;
143extern bool gDebugFlag2;
144extern bool gDebugFlag3;
145extern bool gDebugFlag4;
146extern bool gDebugFlag5;
147extern bool gDebugFlag6;
148
149// synchronized output to stdout with << (i.e. DEBUGOUT(gDebugFlag1, SIMTIME << " var=" << var << "\n")
150#define DEBUGOUT(cond, msg) if (cond) {std::ostringstream oss; oss << msg; std::cout << oss.str();}
151
153double truncate(double x, int fractionBits);
154
156double roundBits(double x, int fractionBits);
157
159double roundDecimal(double x, int precision);
160
162double roundDecimalToEven(double x, int precision);
163
169int getScalingQuota(double frac, int loaded);
int gPrecisionEmissions
Definition StdDefs.cpp:28
T MIN4(T a, T b, T c, T d)
Definition StdDefs.h:107
int GUIDesignDialogButtonsHeight
the default height for dialog buttons
Definition StdDefs.cpp:41
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
bool gRoutingPreferences
Definition StdDefs.cpp:37
double roundDecimalToEven(double x, int precision)
round to the given number of decimal digits (bankers rounding)
Definition StdDefs.cpp:66
int getScalingQuota(double frac, int loaded)
Returns the number of instances of the current object that shall be emitted given the number of loade...
Definition StdDefs.cpp:72
const double SUMO_const_laneWidth
Definition StdDefs.h:52
const double SUMO_const_quarterLaneWidth
Definition StdDefs.h:54
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition StdDefs.cpp:50
const int INVALID_INT
invalid int
Definition StdDefs.h:65
const double SUMO_const_waitingPersonDepth
Definition StdDefs.h:57
int gPrecision
the precision for floating point outputs
Definition StdDefs.cpp:27
T MIN3(T a, T b, T c)
Definition StdDefs.h:93
T MIN2(T a, T b)
Definition StdDefs.h:80
bool gDebugFlag3
Definition StdDefs.cpp:45
double gWeightsRandomFactor
Definition StdDefs.cpp:35
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition StdDefs.cpp:54
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Definition StdDefs.h:71
double gWeightsWalkOppositeFactor
Definition StdDefs.cpp:36
int gPrecisionRandom
Definition StdDefs.cpp:30
bool gDebugFlag5
Definition StdDefs.cpp:47
const double SUMO_const_laneMarkWidth
Definition StdDefs.h:55
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition StdDefs.h:62
T MAX2(T a, T b)
Definition StdDefs.h:86
bool gLocaleInitialized
Definition StdDefs.cpp:34
std::string gLanguage
the language for GUI elements and messages
Definition StdDefs.cpp:38
const double SUMO_const_halfLaneWidth
Definition StdDefs.h:53
bool gSimulation
Definition StdDefs.cpp:32
T MAX4(T a, T b, T c, T d)
Definition StdDefs.h:114
bool gDebugFlag2
Definition StdDefs.cpp:44
bool gHumanReadableTime
Definition StdDefs.cpp:31
T MAX3(T a, T b, T c)
Definition StdDefs.h:100
const double SUMO_const_waitingContainerWidth
Definition StdDefs.h:58
const MMVersion NETWORK_VERSION(1, 20)
bool gIgnoreUnknownVClass
Definition StdDefs.cpp:33
bool gDebugFlag6
Definition StdDefs.cpp:48
double roundDecimal(double x, int precision)
round to the given number of decimal digits
Definition StdDefs.cpp:60
const double SUMO_const_waitingPersonWidth
Definition StdDefs.h:56
bool gDebugFlag4
Definition StdDefs.cpp:46
bool gDebugFlag1
global utility flags for debugging
Definition StdDefs.cpp:43
const double SUMO_const_waitingContainerDepth
Definition StdDefs.h:59
int gPrecisionGeo
Definition StdDefs.cpp:29
int GUIDesignHeight
the default height for GUI elements
Definition StdDefs.cpp:40