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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 //
21 /****************************************************************************/
22 #ifndef StdDefs_h
23 #define StdDefs_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 #include <string>
35 #include <cmath>
36 #include <limits>
37 
38 /* avoiding compiler warning unreferenced parameter */
39 #define UNUSED_PARAMETER(x) ((void)(x))
40 
42 #define SUMO_MAX_CONNECTIONS 256
43 
44 class RGBColor;
45 
46 /* -------------------------------------------------------------------------
47  * some constant defaults used by SUMO
48  * ----------------------------------------------------------------------- */
49 const double SUMO_const_laneWidth = (double) 3.2;
50 const double SUMO_const_halfLaneWidth = (double) 1.6;
51 const double SUMO_const_quarterLaneWidth = (double) 0.8;
52 const double SUMO_const_laneOffset = (double) .1;
53 const double SUMO_const_laneWidthAndOffset = (double) 3.3;
54 const double SUMO_const_halfLaneAndOffset = (double)(3.2 / 2. + .1);
55 
57 const double SUMO_const_haltingSpeed = (double) 0.1;
58 
59 const double INVALID_DOUBLE = std::numeric_limits<double>::max();
60 
61 
62 /* -------------------------------------------------------------------------
63  * templates for mathematical functions missing in some c++-implementations
64  * ----------------------------------------------------------------------- */
65 template<typename T>
66 inline T
67 MIN2(T a, T b) {
68  return a < b ? a : b;
69 }
70 
71 template<typename T>
72 inline T
73 MAX2(T a, T b) {
74  return a > b ? a : b;
75 }
76 
77 
78 template<typename T>
79 inline T
80 MIN3(T a, T b, T c) {
81  return MIN2(c, a < b ? a : b);
82 }
83 
84 
85 template<typename T>
86 inline T
87 MAX3(T a, T b, T c) {
88  return MAX2(c, a > b ? a : b);
89 }
90 
91 
92 template<typename T>
93 inline T
94 MIN4(T a, T b, T c, T d) {
95  return MIN2(MIN2(a, b), MIN2(c, d));
96 }
97 
98 
99 template<typename T>
100 inline T
101 MAX4(T a, T b, T c, T d) {
102  return MAX2(MAX2(a, b), MAX2(c, d));
103 }
104 
105 
106 template<typename T>
107 inline T
108 ISNAN(T a) {
109  volatile T d = a;
110  return d != d;
111 }
112 
113 
115 extern int gPrecision;
116 extern int gPrecisionGeo; // for lon,lat
117 
118 
120 extern bool gDebugFlag1;
121 extern bool gDebugFlag2;
122 extern bool gDebugFlag3;
123 extern bool gDebugFlag4;
124 
126 double truncate(double x, int fractionBits);
127 
129 double roundBits(double x, int fractionBits);
130 
131 #endif
132 
133 /****************************************************************************/
134 
int gPrecisionGeo
Definition: StdDefs.cpp:30
bool gDebugFlag2
Definition: StdDefs.cpp:33
T MIN4(T a, T b, T c, T d)
Definition: StdDefs.h:94
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:54
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:53
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
T MAX2(T a, T b)
Definition: StdDefs.h:73
const double SUMO_const_laneOffset
Definition: StdDefs.h:52
T MAX3(T a, T b, T c)
Definition: StdDefs.h:87
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:29
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:50
T MAX4(T a, T b, T c, T d)
Definition: StdDefs.h:101
T MIN2(T a, T b)
Definition: StdDefs.h:67
const double SUMO_const_quarterLaneWidth
Definition: StdDefs.h:51
T ISNAN(T a)
Definition: StdDefs.h:108
bool gDebugFlag4
Definition: StdDefs.cpp:35
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
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:80
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:59
bool gDebugFlag3
Definition: StdDefs.cpp:34