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-2024 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#define FALLTHROUGH /* do nothing */
34#elif __GNUC__ < 7
35#define FALLTHROUGH /* do nothing */
36#else
37#define FALLTHROUGH __attribute__((fallthrough))
38#endif
39
41#define SUMO_MAX_CONNECTIONS 256
42
43class RGBColor;
44
45/* -------------------------------------------------------------------------
46 * some constant defaults used by SUMO
47 * ----------------------------------------------------------------------- */
48const double SUMO_const_laneWidth = 3.2;
51const double SUMO_const_laneMarkWidth = 0.1;
56
58const double SUMO_const_haltingSpeed = (double) 0.1;
59
61const int INVALID_INT = std::numeric_limits<int>::max();
62
64const double INVALID_DOUBLE = std::numeric_limits<double>::max();
65
67typedef std::pair<int, double> MMVersion;
69
70/* -------------------------------------------------------------------------
71 * templates for mathematical functions missing in some c++-implementations
72 * ----------------------------------------------------------------------- */
73
74template<typename T>
75inline T
76MIN2(T a, T b) {
77 return a < b ? a : b;
78}
79
80template<typename T>
81inline T
82MAX2(T a, T b) {
83 return a > b ? a : b;
84}
85
86
87template<typename T>
88inline T
89MIN3(T a, T b, T c) {
90 return MIN2(c, a < b ? a : b);
91}
92
93
94template<typename T>
95inline T
96MAX3(T a, T b, T c) {
97 return MAX2(c, a > b ? a : b);
98}
99
100
101template<typename T>
102inline T
103MIN4(T a, T b, T c, T d) {
104 return MIN2(MIN2(a, b), MIN2(c, d));
105}
106
107
108template<typename T>
109inline T
110MAX4(T a, T b, T c, T d) {
111 return MAX2(MAX2(a, b), MAX2(c, d));
112}
113
114
116extern int gPrecision;
117extern int gPrecisionGeo; // for lon,lat
118extern int gPrecisionRandom; // for randomized values (i.e. speedFactor)
119extern bool gHumanReadableTime;
120extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
121extern bool gIgnoreUnknownVClass; // whether the unknown vehicle classes shall be ignored on loading (for upward compatibility)
122extern double gWeightsRandomFactor; // randomization for edge weights
123extern double gWeightsWalkOppositeFactor; // factor for walking against flow of traffic
124
126extern std::string gLanguage;
127
129extern int GUIDesignHeight;
130
131
133extern bool gDebugFlag1;
134extern bool gDebugFlag2;
135extern bool gDebugFlag3;
136extern bool gDebugFlag4;
137extern bool gDebugFlag5;
138extern bool gDebugFlag6;
139
140// synchronized output to stdout with << (i.e. DEBUGOUT(gDebugFlag1, SIMTIME << " var=" << var << "\n")
141#define DEBUGOUT(cond, msg) if (cond) {std::ostringstream oss; oss << msg; std::cout << oss.str();}
142
144double truncate(double x, int fractionBits);
145
147double roundBits(double x, int fractionBits);
148
150double roundDecimal(double x, int precision);
151
157int getScalingQuota(double frac, int loaded);
T MIN4(T a, T b, T c, T d)
Definition StdDefs.h:103
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
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:61
const double SUMO_const_laneWidth
Definition StdDefs.h:48
const double SUMO_const_quarterLaneWidth
Definition StdDefs.h:50
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition StdDefs.cpp:44
const int INVALID_INT
invalid int
Definition StdDefs.h:61
const double SUMO_const_waitingPersonDepth
Definition StdDefs.h:53
int gPrecision
the precision for floating point outputs
Definition StdDefs.cpp:26
T MIN3(T a, T b, T c)
Definition StdDefs.h:89
T MIN2(T a, T b)
Definition StdDefs.h:76
bool gDebugFlag3
Definition StdDefs.cpp:39
double gWeightsRandomFactor
Definition StdDefs.cpp:32
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition StdDefs.cpp:48
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Definition StdDefs.h:67
double gWeightsWalkOppositeFactor
Definition StdDefs.cpp:33
int gPrecisionRandom
Definition StdDefs.cpp:28
bool gDebugFlag5
Definition StdDefs.cpp:41
const double SUMO_const_laneMarkWidth
Definition StdDefs.h:51
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition StdDefs.h:58
T MAX2(T a, T b)
Definition StdDefs.h:82
std::string gLanguage
the language for GUI elements and messages
Definition StdDefs.cpp:34
const double SUMO_const_halfLaneWidth
Definition StdDefs.h:49
bool gSimulation
Definition StdDefs.cpp:30
T MAX4(T a, T b, T c, T d)
Definition StdDefs.h:110
bool gDebugFlag2
Definition StdDefs.cpp:38
bool gHumanReadableTime
Definition StdDefs.cpp:29
T MAX3(T a, T b, T c)
Definition StdDefs.h:96
const double SUMO_const_waitingContainerWidth
Definition StdDefs.h:54
const MMVersion NETWORK_VERSION(1, 20)
bool gIgnoreUnknownVClass
Definition StdDefs.cpp:31
bool gDebugFlag6
Definition StdDefs.cpp:42
double roundDecimal(double x, int precision)
round to the given number of decimal digits
Definition StdDefs.cpp:54
const double SUMO_const_waitingPersonWidth
Definition StdDefs.h:52
bool gDebugFlag4
Definition StdDefs.cpp:40
bool gDebugFlag1
global utility flags for debugging
Definition StdDefs.cpp:37
const double SUMO_const_waitingContainerDepth
Definition StdDefs.h:55
int gPrecisionGeo
Definition StdDefs.cpp:27
int GUIDesignHeight
the default size for GUI elements
Definition StdDefs.cpp:35