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-2018 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 <config.h>
28 #include <string>
29 #include <cmath>
30 #include <limits>
31 
32 /* avoiding compiler warning unreferenced parameter */
33 #define UNUSED_PARAMETER(x) ((void)(x))
34 
35 #ifdef _MSC_VER
36 #define FALLTHROUGH /* do nothing */
37 #elif __GNUC__ < 7
38 #define FALLTHROUGH /* do nothing */
39 #else
40 #define FALLTHROUGH __attribute__((fallthrough))
41 #endif
42 
44 #define SUMO_MAX_CONNECTIONS 256
45 
46 class RGBColor;
47 
48 /* -------------------------------------------------------------------------
49  * some constant defaults used by SUMO
50  * ----------------------------------------------------------------------- */
51 const double SUMO_const_laneWidth = (double) 3.2;
52 const double SUMO_const_laneOffset = (double) 0;
57 const double SUMO_const_laneMarkWidth = (double) 0.1;
58 
60 const double SUMO_const_haltingSpeed = (double) 0.1;
61 
62 const double INVALID_DOUBLE = std::numeric_limits<double>::max();
63 
64 
65 /* -------------------------------------------------------------------------
66  * templates for mathematical functions missing in some c++-implementations
67  * ----------------------------------------------------------------------- */
68 template<typename T>
69 inline T
70 MIN2(T a, T b) {
71  return a < b ? a : b;
72 }
73 
74 template<typename T>
75 inline T
76 MAX2(T a, T b) {
77  return a > b ? a : b;
78 }
79 
80 
81 template<typename T>
82 inline T
83 MIN3(T a, T b, T c) {
84  return MIN2(c, a < b ? a : b);
85 }
86 
87 
88 template<typename T>
89 inline T
90 MAX3(T a, T b, T c) {
91  return MAX2(c, a > b ? a : b);
92 }
93 
94 
95 template<typename T>
96 inline T
97 MIN4(T a, T b, T c, T d) {
98  return MIN2(MIN2(a, b), MIN2(c, d));
99 }
100 
101 
102 template<typename T>
103 inline T
104 MAX4(T a, T b, T c, T d) {
105  return MAX2(MAX2(a, b), MAX2(c, d));
106 }
107 
108 
109 template<typename T>
110 inline T
111 ISNAN(T a) {
112  volatile T d = a;
113  return d != d;
114 }
115 
116 
118 extern int gPrecision;
119 extern int gPrecisionGeo; // for lon,lat
120 extern bool gHumanReadableTime;
121 extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
122 
123 
125 extern bool gDebugFlag1;
126 extern bool gDebugFlag2;
127 extern bool gDebugFlag3;
128 extern bool gDebugFlag4;
129 
131 double truncate(double x, int fractionBits);
132 
134 double roundBits(double x, int fractionBits);
135 
136 #endif
137 
138 /****************************************************************************/
139 
int gPrecisionGeo
Definition: StdDefs.cpp:28
bool gDebugFlag2
Definition: StdDefs.cpp:33
bool gSimulation
Definition: StdDefs.cpp:30
T MIN4(T a, T b, T c, T d)
Definition: StdDefs.h:97
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:56
const double SUMO_const_laneWidth
Definition: StdDefs.h:51
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:55
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
T MAX2(T a, T b)
Definition: StdDefs.h:76
const double SUMO_const_laneOffset
Definition: StdDefs.h:52
T MAX3(T a, T b, T c)
Definition: StdDefs.h:90
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:53
T MAX4(T a, T b, T c, T d)
Definition: StdDefs.h:104
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:57
T MIN2(T a, T b)
Definition: StdDefs.h:70
const double SUMO_const_quarterLaneWidth
Definition: StdDefs.h:54
T ISNAN(T a)
Definition: StdDefs.h:111
bool gHumanReadableTime
Definition: StdDefs.cpp:29
bool gDebugFlag4
Definition: StdDefs.cpp:35
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:37
T MIN3(T a, T b, T c)
Definition: StdDefs.h:83
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:41
const double INVALID_DOUBLE
Definition: StdDefs.h:62
bool gDebugFlag3
Definition: StdDefs.cpp:34