Eclipse SUMO - Simulation of Urban MObility
GenericEngineModel.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Generic interface for an engine model
16 /****************************************************************************/
17 
18 #include <config.h>
19 
20 #include <iostream>
22 #include "GenericEngineModel.h"
23 
24 
25 void GenericEngineModel::printParameterError(std::string parameter, std::string value) {
26  std::cerr << className << ": invalid value " << value << " for parameter " << parameter << std::endl;
27 }
28 
29 void GenericEngineModel::parseParameter(const ParMap& parameters, std::string parameter, double& value) {
30  ParMap::const_iterator par = parameters.find(parameter);
31  if (par != parameters.end()) {
32  try {
33  value = StringUtils::toDouble(par->second);
34  } catch (ProcessError&) {
35  printParameterError(par->first, par->second);
36  }
37  }
38 }
39 void GenericEngineModel::parseParameter(const ParMap& parameters, std::string parameter, int& value) {
40  ParMap::const_iterator par = parameters.find(parameter);
41  if (par != parameters.end()) {
42  try {
43  value = StringUtils::toInt(par->second);
44  } catch (ProcessError&) {
45  printParameterError(par->first, par->second);
46  }
47  }
48 }
49 void GenericEngineModel::parseParameter(const ParMap& parameters, std::string parameter, std::string& value) {
50  ParMap::const_iterator par = parameters.find(parameter);
51  if (par != parameters.end()) {
52  value = par->second;
53  }
54 }
56  this->maxAcceleration_mpsps = maxAcceleration_mpsps;
57 }
59  this->maxDeceleration_mpsps = maxDeceleration_mpsps;
60 }
62  return maxAcceleration_mpsps;
63 }
65  return maxDeceleration_mpsps;
66 }
void parseParameter(const ParMap &parameters, std::string parameter, double &value)
void printParameterError(std::string parameter, std::string value)
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...
std::map< std::string, std::string > ParMap