Eclipse SUMO - Simulation of Urban MObility
StdDefs.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 //
19 /****************************************************************************/
20 #ifndef StdDefs_h
21 #define StdDefs_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <string>
28 #include <cmath>
29 #include <limits>
30 
31 /* avoiding compiler warning unreferenced parameter */
32 #define UNUSED_PARAMETER(x) ((void)(x))
33 
34 #ifdef _MSC_VER
35 #define FALLTHROUGH /* do nothing */
36 #elif __GNUC__ < 7
37 #define FALLTHROUGH /* do nothing */
38 #else
39 #define FALLTHROUGH __attribute__((fallthrough))
40 #endif
41 
43 #define SUMO_MAX_CONNECTIONS 256
44 
45 class RGBColor;
46 
47 /* -------------------------------------------------------------------------
48  * some constant defaults used by SUMO
49  * ----------------------------------------------------------------------- */
50 const double SUMO_const_laneWidth = (double) 3.2;
51 const double SUMO_const_laneOffset = (double) 0;
56 const double SUMO_const_laneMarkWidth = (double) 0.1;
57 const double SUMO_const_waitingPersonWidth = 0.8;
58 const double SUMO_const_waitingPersonDepth = 0.67;
59 
61 const double SUMO_const_haltingSpeed = (double) 0.1;
62 
63 const double INVALID_DOUBLE = std::numeric_limits<double>::max();
64 
66 const double NETWORK_VERSION = 1.3;
67 
68 
69 /* -------------------------------------------------------------------------
70  * templates for mathematical functions missing in some c++-implementations
71  * ----------------------------------------------------------------------- */
72 template<typename T>
73 inline T
74 MIN2(T a, T b) {
75  return a < b ? a : b;
76 }
77 
78 template<typename T>
79 inline T
80 MAX2(T a, T b) {
81  return a > b ? a : b;
82 }
83 
84 
85 template<typename T>
86 inline T
87 MIN3(T a, T b, T c) {
88  return MIN2(c, a < b ? a : b);
89 }
90 
91 
92 template<typename T>
93 inline T
94 MAX3(T a, T b, T c) {
95  return MAX2(c, a > b ? a : b);
96 }
97 
98 
99 template<typename T>
100 inline T
101 MIN4(T a, T b, T c, T d) {
102  return MIN2(MIN2(a, b), MIN2(c, d));
103 }
104 
105 
106 template<typename T>
107 inline T
108 MAX4(T a, T b, T c, T d) {
109  return MAX2(MAX2(a, b), MAX2(c, d));
110 }
111 
112 
113 template<typename T>
114 inline T
115 ISNAN(T a) {
116  volatile T d = a;
117  return d != d;
118 }
119 
120 
122 extern int gPrecision;
123 extern int gPrecisionGeo; // for lon,lat
124 extern bool gHumanReadableTime;
125 extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
126 extern double gWeightsRandomFactor; // randomization for edge weights
127 
128 
130 extern bool gDebugFlag1;
131 extern bool gDebugFlag2;
132 extern bool gDebugFlag3;
133 extern bool gDebugFlag4;
134 
136 double truncate(double x, int fractionBits);
137 
139 double roundBits(double x, int fractionBits);
140 
141 #endif
142 
143 /****************************************************************************/
144 
int gPrecisionGeo
Definition: StdDefs.cpp:28
bool gDebugFlag2
Definition: StdDefs.cpp:34
bool gSimulation
Definition: StdDefs.cpp:30
T MIN4(T a, T b, T c, T d)
Definition: StdDefs.h:101
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:55
const double SUMO_const_laneWidth
Definition: StdDefs.h:50
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:54
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:33
T MAX2(T a, T b)
Definition: StdDefs.h:80
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:57
const double SUMO_const_laneOffset
Definition: StdDefs.h:51
T MAX3(T a, T b, T c)
Definition: StdDefs.h:94
double gWeightsRandomFactor
Definition: StdDefs.cpp:31
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:52
T MAX4(T a, T b, T c, T d)
Definition: StdDefs.h:108
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:56
const double SUMO_const_waitingPersonDepth
Definition: StdDefs.h:58
T MIN2(T a, T b)
Definition: StdDefs.h:74
const double SUMO_const_quarterLaneWidth
Definition: StdDefs.h:53
T ISNAN(T a)
Definition: StdDefs.h:115
bool gHumanReadableTime
Definition: StdDefs.cpp:29
bool gDebugFlag4
Definition: StdDefs.cpp:36
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:61
const double NETWORK_VERSION
version for written networks and default version for loading
Definition: StdDefs.h:66
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:38
T MIN3(T a, T b, T c)
Definition: StdDefs.h:87
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:42
const double INVALID_DOUBLE
Definition: StdDefs.h:63
bool gDebugFlag3
Definition: StdDefs.cpp:35