LCOV - code coverage report
Current view: top level - src/utils/common - StdDefs.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 4 4
Test Date: 2025-11-13 15:38:19 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2005-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    StdDefs.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Laura Bieker
      17              : /// @author  Michael Behrisch
      18              : /// @author  Jakob Erdmann
      19              : /// @date    Fri, 29.04.2005
      20              : ///
      21              : //
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : #include <string>
      26              : #include <cmath>
      27              : #include <limits>
      28              : 
      29              : /* avoiding compiler warning unreferenced parameter */
      30              : #define UNUSED_PARAMETER(x)  ((void)(x))
      31              : 
      32              : #ifdef _MSC_VER
      33              : #if _MSC_VER < 1943
      34              : #define FALLTHROUGH /* do nothing */
      35              : #else
      36              : #define FALLTHROUGH [[fallthrough]]
      37              : #endif
      38              : #elif __GNUC__ < 7
      39              : #define FALLTHROUGH /* do nothing */
      40              : #else
      41              : #define FALLTHROUGH __attribute__((fallthrough))
      42              : #endif
      43              : 
      44              : /// @brief the maximum number of connections across an intersection
      45              : #define  SUMO_MAX_CONNECTIONS 256
      46              : 
      47              : class RGBColor;
      48              : 
      49              : /* -------------------------------------------------------------------------
      50              :  * some constant defaults used by SUMO
      51              :  * ----------------------------------------------------------------------- */
      52              : const double SUMO_const_laneWidth = 3.2;
      53              : const double SUMO_const_halfLaneWidth = SUMO_const_laneWidth / 2;
      54              : const double SUMO_const_quarterLaneWidth = SUMO_const_laneWidth / 4;
      55              : const double SUMO_const_laneMarkWidth = 0.1;
      56              : const double SUMO_const_waitingPersonWidth = 0.8;
      57              : const double SUMO_const_waitingPersonDepth = 0.67;
      58              : const double SUMO_const_waitingContainerWidth = 2.5;
      59              : const double SUMO_const_waitingContainerDepth = 6.2;
      60              : 
      61              : /// @brief the speed threshold at which vehicles are considered as halting
      62              : const double SUMO_const_haltingSpeed = (double) 0.1;
      63              : 
      64              : /// @brief invalid int
      65              : const int INVALID_INT = std::numeric_limits<int>::max();
      66              : 
      67              : /// @brief invalid double
      68              : const double INVALID_DOUBLE = std::numeric_limits<double>::max();
      69              : 
      70              : /// @brief (M)ajor/(M)inor version for written networks and default version for loading
      71              : typedef std::pair<int, double> MMVersion;
      72              : const MMVersion NETWORK_VERSION(1, 20);
      73              : 
      74              : /* -------------------------------------------------------------------------
      75              :  * templates for mathematical functions missing in some c++-implementations
      76              :  * ----------------------------------------------------------------------- */
      77              : 
      78              : template<typename T>
      79              : inline T
      80              : MIN2(T a, T b) {
      81  84353687246 :     return a < b ? a : b;
      82              : }
      83              : 
      84              : template<typename T>
      85              : inline T
      86              : MAX2(T a, T b) {
      87  60760661408 :     return a > b ? a : b;
      88              : }
      89              : 
      90              : 
      91              : template<typename T>
      92              : inline T
      93              : MIN3(T a, T b, T c) {
      94    886541930 :     return MIN2(c, a < b ? a : b);
      95              : }
      96              : 
      97              : 
      98              : template<typename T>
      99              : inline T
     100              : MAX3(T a, T b, T c) {
     101    966203179 :     return MAX2(c, a > b ? a : b);
     102              : }
     103              : 
     104              : 
     105              : template<typename T>
     106              : inline T
     107              : MIN4(T a, T b, T c, T d) {
     108              :     return MIN2(MIN2(a, b), MIN2(c, d));
     109              : }
     110              : 
     111              : 
     112              : template<typename T>
     113              : inline T
     114              : MAX4(T a, T b, T c, T d) {
     115              :     return MAX2(MAX2(a, b), MAX2(c, d));
     116              : }
     117              : 
     118              : 
     119              : /// the precision for floating point outputs
     120              : extern int gPrecision;
     121              : extern int gPrecisionEmissions;
     122              : extern int gPrecisionGeo; // for lon,lat
     123              : extern int gPrecisionRandom; // for randomized values (i.e. speedFactor)
     124              : extern bool gHumanReadableTime;
     125              : extern bool gSimulation; // whether the current application is sumo or sumo-gui (as opposed to a router)
     126              : extern bool gIgnoreUnknownVClass; // whether the unknown vehicle classes shall be ignored on loading (for upward compatibility)
     127              : extern bool gLocaleInitialized; // whether the gettext locale for translating messages has already been loaded
     128              : extern double gWeightsRandomFactor; // randomization for edge weights
     129              : extern double gWeightsWalkOppositeFactor; // factor for walking against flow of traffic
     130              : extern bool gRoutingPreferences; // whether routing preferences have been loaded
     131              : 
     132              : /// the language for GUI elements and messages
     133              : extern std::string gLanguage;
     134              : 
     135              : /// the default height for GUI elements
     136              : extern int GUIDesignHeight;
     137              : 
     138              : /// the default height for dialog buttons
     139              : extern int GUIDesignDialogButtonsHeight;
     140              : 
     141              : /// @brief global utility flags for debugging
     142              : extern bool gDebugFlag1;
     143              : extern bool gDebugFlag2;
     144              : extern bool gDebugFlag3;
     145              : extern bool gDebugFlag4;
     146              : extern bool gDebugFlag5;
     147              : extern bool gDebugFlag6;
     148              : 
     149              : // synchronized output to stdout with << (i.e. DEBUGOUT(gDebugFlag1, SIMTIME << " var=" << var << "\n")
     150              : #define DEBUGOUT(cond, msg) if (cond) {std::ostringstream oss; oss << msg; std::cout << oss.str();}
     151              : 
     152              : /// @brief discrds mantissa bits beyond the given number
     153              : double truncate(double x, int fractionBits);
     154              : 
     155              : /// @brief round to the given number of mantissa bits beyond the given number
     156              : double roundBits(double x, int fractionBits);
     157              : 
     158              : /// @brief round to the given number of decimal digits
     159              : double roundDecimal(double x, int precision);
     160              : 
     161              : /// @brief round to the given number of decimal digits (bankers rounding)
     162              : double roundDecimalToEven(double x, int precision);
     163              : 
     164              : /** @brief Returns the number of instances of the current object that shall be emitted
     165              :  * given the number of loaded objects
     166              :  * considering that "frac" of all objects shall be emitted overall
     167              :  * @return the number of objects to create (something between 0 and ceil(frac))
     168              :  */
     169              : int getScalingQuota(double frac, int loaded);
        

Generated by: LCOV version 2.0-1