ATLAS Offline Software
IUnitInterpreter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // IUnitInterpreter.cxx, (c) ATLAS Detector software
8 // Author: Thomas Gillam (thomas.gillam@cern.ch)
9 // ExpressionParsing library
11 
13 
14 #include <stdexcept>
15 
16 namespace ExpressionParsing {
17  bool IUnitInterpreter::isKnownUnit(const std::string &unitname) const
18  {
19  return (unitMap().count(unitname) > 0);
20  }
21 
22  double IUnitInterpreter::unitValue(const std::string &unitname) const
23  {
24  typedef std::map<std::string, double>::const_iterator Iterator;
25  const std::map<std::string, double> &theMap = unitMap();
26  for (Iterator it = theMap.begin(); it != theMap.end(); ++it) {
27  if (it->first == unitname) {
28  return it->second;
29  }
30  }
31 
32  throw std::runtime_error("Trying to access unknown unit: "+unitname);
33  }
34 }
ExpressionParsing::IUnitInterpreter::unitMap
virtual const std::map< std::string, double > & unitMap() const =0
skel.it
it
Definition: skel.GENtoEVGEN.py:396
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
ExpressionParsing::IUnitInterpreter::isKnownUnit
bool isKnownUnit(const std::string &unitname) const
Definition: IUnitInterpreter.cxx:17
ExpressionParsing
Namespace holding all the expression evaluation code.
Definition: ExpressionParser.h:26
ExpressionParsing::IUnitInterpreter::unitValue
double unitValue(const std::string &unitname) const
Definition: IUnitInterpreter.cxx:22
IUnitInterpreter.h