Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GenericEngineModel.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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// Generic interface for an engine model
19/****************************************************************************/
20
21#include <config.h>
22
23#include <iostream>
25#include "GenericEngineModel.h"
26
27
28void GenericEngineModel::printParameterError(std::string parameter, std::string value) {
29 std::cerr << className << ": invalid value " << value << " for parameter " << parameter << std::endl;
30}
31
32void GenericEngineModel::parseParameter(const Parameterised::Map& parameters, std::string parameter, double& value) {
33 Parameterised::Map::const_iterator par = parameters.find(parameter);
34 if (par != parameters.end()) {
35 try {
36 value = StringUtils::toDouble(par->second);
37 } catch (ProcessError&) {
38 printParameterError(par->first, par->second);
39 }
40 }
41}
42void GenericEngineModel::parseParameter(const Parameterised::Map& parameters, std::string parameter, int& value) {
43 Parameterised::Map::const_iterator par = parameters.find(parameter);
44 if (par != parameters.end()) {
45 try {
46 value = StringUtils::toInt(par->second);
47 } catch (ProcessError&) {
48 printParameterError(par->first, par->second);
49 }
50 }
51}
52void GenericEngineModel::parseParameter(const Parameterised::Map& parameters, std::string parameter, std::string& value) {
53 Parameterised::Map::const_iterator par = parameters.find(parameter);
54 if (par != parameters.end()) {
55 value = par->second;
56 }
57}
void setMaximumAcceleration(double maxAcc)
void parseParameter(const Parameterised::Map &parameters, std::string parameter, double &value)
void setMaximumDeceleration(double maxDec)
void printParameterError(std::string parameter, std::string value)
std::map< std::string, std::string > Map
parameters map
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...