LCOV - code coverage report
Current view: top level - src/utils/emissions - EnergyParams.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 7 7
Test Date: 2024-11-21 15:56:26 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2002-2024 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    EnergyParams.h
      15              : /// @author  Jakob Erdmann
      16              : /// @date    Sept 2021
      17              : ///
      18              : // A class for parameters used by the emission models
      19              : /****************************************************************************/
      20              : #pragma once
      21              : #include <config.h>
      22              : #include <map>
      23              : #include <string>
      24              : #include <vector>
      25              : #include <utils/common/SUMOVehicleClass.h>
      26              : #include <utils/emissions/CharacteristicMap.h>
      27              : #include <utils/xml/SUMOXMLDefinitions.h>
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // class declarations
      32              : // ===========================================================================
      33              : class SUMOVTypeParameter;
      34              : 
      35              : 
      36              : // ===========================================================================
      37              : // class definitions
      38              : // ===========================================================================
      39              : /**
      40              :  * @class EnergyParams
      41              :  * @brief An upper class for objects with additional parameters
      42              :  */
      43              : class EnergyParams {
      44              : public:
      45              :     /// @brief Constructor
      46              :     EnergyParams(const SUMOVTypeParameter* typeParams = nullptr);
      47              : 
      48              :     /// @brief Constructor
      49              :     EnergyParams(const SUMOEmissionClass c);
      50              : 
      51              :     /// @brief Constructor
      52       861198 :     EnergyParams(const EnergyParams* secondaryParams) : mySecondaryParams(secondaryParams) {}
      53              : 
      54              :     /// @brief Destructor
      55              :     ~EnergyParams();
      56              : 
      57              :     /**@brief Set secondary params
      58              :      * @param[in] secondaryParams The secondary parameters
      59              :      */
      60              :     void setSecondary(const EnergyParams* secondaryParams) {
      61         6367 :         mySecondaryParams = secondaryParams;
      62         6367 :     }
      63              : 
      64              :     /**@brief Sets a parameter
      65              :      * @param[in] key The parameter's name
      66              :      * @param[in] value The parameter's value
      67              :      */
      68              :     void setDouble(SumoXMLAttr attr, double value);
      69              : 
      70              :     double getDouble(SumoXMLAttr attr) const;
      71              :     double getDoubleOptional(SumoXMLAttr attr, const double def) const;
      72              : 
      73              :     /**@brief Returns the value for a given key
      74              :      * @param[in] key The key to ask for
      75              :      * @return The value stored under the key
      76              :      */
      77              :     const std::vector<double>& getDoubles(SumoXMLAttr attr) const;
      78              : 
      79              :     /**
      80              :      * @brief Return the CharacteristicMap that belongs to a given attribute.
      81              :      *
      82              :      * @param[in] attr Name of an attribute
      83              :      * @return A CharacteristicMap
      84              :      */
      85              :     const CharacteristicMap& getCharacteristicMap(SumoXMLAttr attr) const;
      86              : 
      87              :     void checkParam(const SumoXMLAttr paramKey, const std::string& id, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
      88              : 
      89              :     /** @brief Returns the state of the engine when the vehicle is not moving
      90              :      * @return whether the engine is running
      91              :      */
      92              :     bool isEngineOff() const;
      93              : 
      94              :     /** @brief Returns whether the vehicle is currently consuming any energy derived from the parking state
      95              :      * @return whether the vehicle has any consumption
      96              :      */
      97              :     bool isOff() const;
      98              : 
      99         3780 :     static const EnergyParams* getDefault() {
     100         3780 :         if (myDefault == nullptr) {
     101           11 :             myDefault = new EnergyParams();
     102              :         }
     103         3780 :         return myDefault;
     104              :     }
     105              : 
     106              : private:
     107              :     /// @brief The key->value maps
     108              :     std::map<SumoXMLAttr, double> myMap;
     109              :     std::map<SumoXMLAttr, std::vector<double> > myVecMap;
     110              :     std::map<SumoXMLAttr, CharacteristicMap> myCharacteristicMapMap;
     111              :     const EnergyParams* mySecondaryParams = nullptr;
     112              : 
     113              :     static const EnergyParams* myDefault;
     114              : };
        

Generated by: LCOV version 2.0-1