Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
EnergyParams.h
Go to the documentation of this file.
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/****************************************************************************/
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>
28
29
30// ===========================================================================
31// class declarations
32// ===========================================================================
34
35
36// ===========================================================================
37// class definitions
38// ===========================================================================
44public:
46 EnergyParams(const SUMOVTypeParameter* typeParams = nullptr);
47
50
52 EnergyParams(const EnergyParams* secondaryParams) : mySecondaryParams(secondaryParams) {}
53
56
60 void setSecondary(const EnergyParams* secondaryParams) {
61 mySecondaryParams = secondaryParams;
62 }
63
68 void setDouble(SumoXMLAttr attr, double value);
69
70 double getDouble(SumoXMLAttr attr) const;
71 double getDoubleOptional(SumoXMLAttr attr, const double def) const;
72
77 const std::vector<double>& getDoubles(SumoXMLAttr attr) const;
78
86
87 void checkParam(const SumoXMLAttr paramKey, const std::string& id, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
88
92 bool isEngineOff() const;
93
97 bool isOff() const;
98
99 static const EnergyParams* getDefault() {
100 if (myDefault == nullptr) {
101 myDefault = new EnergyParams();
102 }
103 return myDefault;
104 }
105
106private:
108 std::map<SumoXMLAttr, double> myMap;
109 std::map<SumoXMLAttr, std::vector<double> > myVecMap;
110 std::map<SumoXMLAttr, CharacteristicMap> myCharacteristicMapMap;
112
113 static const EnergyParams* myDefault;
114};
int SUMOEmissionClass
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.
double getDouble(SumoXMLAttr attr) const
bool isOff() const
Returns whether the vehicle is currently consuming any energy derived from the parking state.
static const EnergyParams * myDefault
void setDouble(SumoXMLAttr attr, double value)
Sets a parameter.
double getDoubleOptional(SumoXMLAttr attr, const double def) const
std::map< SumoXMLAttr, double > myMap
The key->value maps.
std::map< SumoXMLAttr, std::vector< double > > myVecMap
std::map< SumoXMLAttr, CharacteristicMap > myCharacteristicMapMap
bool isEngineOff() const
Returns the state of the engine when the vehicle is not moving.
EnergyParams(const EnergyParams *secondaryParams)
Constructor.
const EnergyParams * mySecondaryParams
const CharacteristicMap & getCharacteristicMap(SumoXMLAttr attr) const
Return the CharacteristicMap that belongs to a given attribute.
void setSecondary(const EnergyParams *secondaryParams)
Set secondary params.
~EnergyParams()
Destructor.
static const EnergyParams * getDefault()
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.