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 /****************************************************************************/
17 //
18 /****************************************************************************/
19 #ifndef StdDefs_h
20 #define StdDefs_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <string>
27 #include <cmath>
28 #include <limits>
29 
30 /* avoiding compiler warning unreferenced parameter */
31 #define UNUSED_PARAMETER(x) ((void)(x))
32 
33 #ifdef _MSC_VER
34 #define FALLTHROUGH /* do nothing */
35 #elif __GNUC__ < 7
36 #define FALLTHROUGH /* do nothing */
37 #else
38 #define FALLTHROUGH __attribute__((fallthrough))
39 #endif
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_laneOffset = (double) 0;
55 const double SUMO_const_laneMarkWidth = (double) 0.1;
56 const double SUMO_const_waitingPersonWidth = 0.8;
57 const double SUMO_const_waitingPersonDepth = 0.67;
58 
60 const double SUMO_const_haltingSpeed = (double) 0.1;
61 
62 const double INVALID_DOUBLE = std::numeric_limits<double>::max();
63 
65 const double NETWORK_VERSION = 1.3;
66 
67 
68 /* -------------------------------------------------------------------------
69  * templates for mathematical functions missing in some c++-implementations
70  * ----------------------------------------------------------------------- */
71 template<typename T>
72 inline T
73 MIN2(T a, T b) {
74  return a < b ? a : b;
75 }
76 
77 template<typename T>
78 inline T
79 MAX2(T a, T b) {
80  return a > b ? a : b;
81 }
82 
83 
84 template<typename T>
85 inline T
86 MIN3(T a, T b, T c) {
87  return MIN2(c, a < b ? a : b);
88 }
89 
90 
91 template<typename T>
92 inline T
93 MAX3(T a, T b, T c) {
94  return MAX2(c, a > b ? a : b);
95 }
96 
97 
98 template<typename T>
99 inline T
100 MIN4(T a, T b, T c, T d) {
101  return MIN2(MIN2(a, b), MIN2(c, d));
102 }
103 
104 
105 template<typename T>
106 inline T
107 MAX4(T a, T b, T c, T d) {
108  return MAX2(MAX2(a, b), MAX2(c, d));
109 }
110 
111 
112 template<typename T>
113 inline T
114 ISNAN(T a) {
115  volatile T d = a;
116  return d != d;
117 }
118 
119 
121 extern int gPrecision;
122 extern int gPrecisionGeo; // for lon,lat
123 extern bool gHumanReadableTime;
124 extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
125 extern double gWeightsRandomFactor; // randomization for edge weights
126 
127 
129 extern bool gDebugFlag1;
130 extern bool gDebugFlag2;
131 extern bool gDebugFlag3;
132 extern bool gDebugFlag4;
133 
134 // synchronized output to stdout with << (i.e. DEBUGOUT(SIMTIME << " var=" << var << "\n")
135 #define DEBUGOUT(msg) {std::ostringstream oss; oss << msg; std::cout << oss.str();}
136 
138 double truncate(double x, int fractionBits);
139 
141 double roundBits(double x, int fractionBits);
142 
143 #endif
144 
145 /****************************************************************************/
146 
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
NETWORK_VERSION
const double NETWORK_VERSION
version for written networks and default version for loading
Definition: StdDefs.h:65
SUMO_const_waitingPersonDepth
const double SUMO_const_waitingPersonDepth
Definition: StdDefs.h:57
SUMO_const_laneWidth
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
gDebugFlag2
bool gDebugFlag2
Definition: StdDefs.cpp:33
MAX3
T MAX3(T a, T b, T c)
Definition: StdDefs.h:93
SUMO_const_laneWidthAndOffset
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:53
SUMO_const_halfLaneAndOffset
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:54
ISNAN
T ISNAN(T a)
Definition: StdDefs.h:114
SUMO_const_haltingSpeed
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
RGBColor
Definition: RGBColor.h:39
roundBits
double roundBits(double x, int fractionBits)
round to the given number of mantissa bits beyond the given number
Definition: StdDefs.cpp:41
SUMO_const_waitingPersonWidth
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:56
SUMO_const_halfLaneWidth
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:51
MAX4
T MAX4(T a, T b, T c, T d)
Definition: StdDefs.h:107
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:30
gSimulation
bool gSimulation
Definition: StdDefs.cpp:29
MIN4
T MIN4(T a, T b, T c, T d)
Definition: StdDefs.h:100
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:27
gDebugFlag4
bool gDebugFlag4
Definition: StdDefs.cpp:35
INVALID_DOUBLE
const double INVALID_DOUBLE
Definition: StdDefs.h:62
SUMO_const_laneMarkWidth
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:55
gDebugFlag3
bool gDebugFlag3
Definition: StdDefs.cpp:34
SUMO_const_quarterLaneWidth
const double SUMO_const_quarterLaneWidth
Definition: StdDefs.h:52
gDebugFlag1
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
truncate
double truncate(double x, int fractionBits)
discrds mantissa bits beyond the given number
Definition: StdDefs.cpp:37
MIN3
T MIN3(T a, T b, T c)
Definition: StdDefs.h:86
gHumanReadableTime
bool gHumanReadableTime
Definition: StdDefs.cpp:28
SUMO_const_laneOffset
const double SUMO_const_laneOffset
Definition: StdDefs.h:50
gPrecision
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:26