Eclipse SUMO - Simulation of Urban MObility
EnergyParams.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2022 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 /****************************************************************************/
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>
27 
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class SUMOVTypeParameter;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
41 class EnergyParams {
42 public:
44  EnergyParams(const SUMOVTypeParameter* typeParams = nullptr);
45 
47  EnergyParams(const EnergyParams* secondaryParams) : mySecondaryParams(secondaryParams) {}
48 
50  ~EnergyParams();
51 
55  void setSecondary(const EnergyParams* secondaryParams) {
56  mySecondaryParams = secondaryParams;
57  }
58 
63  void setDouble(SumoXMLAttr attr, double value);
64 
65  double getDouble(SumoXMLAttr attr) const;
66 
71  const std::vector<double>& getDoubles(SumoXMLAttr attr) const;
72 
80 
81  void checkParam(const SumoXMLAttr paramKey, const std::string& id, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
82 
86  bool isEngineOff() const;
87 
91  bool isOff() const;
92 
93  static const EnergyParams* getDefault() {
94  if (myDefault == nullptr) {
95  myDefault = new EnergyParams();
96  }
97  return myDefault;
98  }
99 
100 private:
102  std::map<SumoXMLAttr, double> myMap;
103  std::map<SumoXMLAttr, std::vector<double> > myVecMap;
104  std::map<SumoXMLAttr, CharacteristicMap> myCharacteristicMapMap;
105  const EnergyParams* mySecondaryParams = nullptr;
106 
107  static const EnergyParams* myDefault;
108 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
The purpose of this class is to store a characteristic map (German: Kennfeld) of arbitrary dimensions...
An upper class for objects with additional parameters.
Definition: EnergyParams.h:41
double getDouble(SumoXMLAttr attr) const
static const EnergyParams * getDefault()
Definition: EnergyParams.h:93
bool isOff() const
Returns whether the vehicle is currently consuming any energy derived from the parking state.
static const EnergyParams * myDefault
Definition: EnergyParams.h:107
void setDouble(SumoXMLAttr attr, double value)
Sets a parameter.
std::map< SumoXMLAttr, double > myMap
The key->value maps.
Definition: EnergyParams.h:102
EnergyParams(const SUMOVTypeParameter *typeParams=nullptr)
Constructor.
std::map< SumoXMLAttr, std::vector< double > > myVecMap
Definition: EnergyParams.h:103
std::map< SumoXMLAttr, CharacteristicMap > myCharacteristicMapMap
Definition: EnergyParams.h:104
bool isEngineOff() const
Returns the state of the engine when the vehicle is not moving.
EnergyParams(const EnergyParams *secondaryParams)
Constructor.
Definition: EnergyParams.h:47
const EnergyParams * mySecondaryParams
Definition: EnergyParams.h:105
const CharacteristicMap & getCharacteristicMap(SumoXMLAttr attr) const
Return the CharacteristicMap that belongs to a given attribute.
void setSecondary(const EnergyParams *secondaryParams)
Set secondary params.
Definition: EnergyParams.h:55
~EnergyParams()
Destructor.
const std::vector< double > & getDoubles(SumoXMLAttr attr) const
Returns the value for a given key.
void checkParam(const SumoXMLAttr paramKey, const std::string &id, const double lower=0., const double upper=std::numeric_limits< double >::infinity())
Structure representing possible vehicle parameter.