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 
36 #define SUMO_MAX_CONNECTIONS 256
37 
38 class RGBColor;
39 
40 /* -------------------------------------------------------------------------
41  * some constant defaults used by SUMO
42  * ----------------------------------------------------------------------- */
43 const double SUMO_const_laneWidth = (double) 3.2;
44 const double SUMO_const_laneOffset = (double) 0;
49 const double SUMO_const_laneMarkWidth = (double) 0.1;
50 
52 const double SUMO_const_haltingSpeed = (double) 0.1;
53 
54 const double INVALID_DOUBLE = std::numeric_limits<double>::max();
55 
56 
57 /* -------------------------------------------------------------------------
58  * templates for mathematical functions missing in some c++-implementations
59  * ----------------------------------------------------------------------- */
60 template<typename T>
61 inline T
62 MIN2(T a, T b) {
63  return a < b ? a : b;
64 }
65 
66 template<typename T>
67 inline T
68 MAX2(T a, T b) {
69  return a > b ? a : b;
70 }
71 
72 
73 template<typename T>
74 inline T
75 MIN3(T a, T b, T c) {
76  return MIN2(c, a < b ? a : b);
77 }
78 
79 
80 template<typename T>
81 inline T
82 MAX3(T a, T b, T c) {
83  return MAX2(c, a > b ? a : b);
84 }
85 
86 
87 template<typename T>
88 inline T
89 MIN4(T a, T b, T c, T d) {
90  return MIN2(MIN2(a, b), MIN2(c, d));
91 }
92 
93 
94 template<typename T>
95 inline T
96 MAX4(T a, T b, T c, T d) {
97  return MAX2(MAX2(a, b), MAX2(c, d));
98 }
99 
100 
101 template<typename T>
102 inline T
103 ISNAN(T a) {
104  volatile T d = a;
105  return d != d;
106 }
107 
108 
110 extern int gPrecision;
111 extern int gPrecisionGeo; // for lon,lat
112 extern bool gHumanReadableTime;
113 extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
114 
115 
117 extern bool gDebugFlag1;
118 extern bool gDebugFlag2;
119 extern bool gDebugFlag3;
120 extern bool gDebugFlag4;
121 
123 double truncate(double x, int fractionBits);
124 
126 double roundBits(double x, int fractionBits);
127 
128 #endif
129 
130 /****************************************************************************/
131 
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:89
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:48
const double SUMO_const_laneWidth
Definition: StdDefs.h:43
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:47
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
T MAX2(T a, T b)
Definition: StdDefs.h:68
const double SUMO_const_laneOffset
Definition: StdDefs.h:44
T MAX3(T a, T b, T c)
Definition: StdDefs.h:82
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:45
T MAX4(T a, T b, T c, T d)
Definition: StdDefs.h:96
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:49
T MIN2(T a, T b)
Definition: StdDefs.h:62
const double SUMO_const_quarterLaneWidth
Definition: StdDefs.h:46
T ISNAN(T a)
Definition: StdDefs.h:103
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:52
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:75
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:54
bool gDebugFlag3
Definition: StdDefs.cpp:34