The Gaudi Framework  v31r0 (aeb156f0)
Interpolation.cpp
Go to the documentation of this file.
3 #include <cassert>
4 #include <iomanip>
5 
6 namespace {
7  const char* table[] = {"Linear", "Polynomial", "Cspline", "Cspline_Periodic", "Akima", "Akima_Periodic"};
8 }
9 
10 using namespace GaudiMath::Interpolation;
11 
12 namespace Gaudi {
13  namespace Parsers {
14 
15  template <typename Iterator, typename Skipper>
16  struct InterpolGrammar : qi::grammar<Iterator, GaudiMath::Interpolation::Type(), Skipper> {
18  InterpolGrammar() : InterpolGrammar::base_type( literal ) {
19  literal = ( qi::lit( table[Linear] ) )[qi::_val = Linear] |
20  ( qi::lit( table[Polynomial] ) )[qi::_val = Polynomial] |
21  ( qi::lit( table[Cspline] ) )[qi::_val = Cspline] |
22  ( qi::lit( table[Cspline_Periodic] ) )[qi::_val = Cspline_Periodic] |
23  ( qi::lit( table[Akima] ) )[qi::_val = Akima] |
24  ( qi::lit( table[Akima_Periodic] ) )[qi::_val = Akima_Periodic];
25  }
26  qi::rule<Iterator, ResultT(), Skipper> literal;
27  };
29  } // namespace Parsers
30 } // namespace Gaudi
31 
32 namespace GaudiMath {
33  namespace Interpolation {
34 
35  StatusCode parse( Type& t, const std::string& in ) { return Gaudi::Parsers::parse_( t, in ); }
36  std::string toString( const Type& t ) {
37  assert( 0 <= t && t <= Type::Akima_Periodic );
38  return table[t];
39  }
40  std::ostream& toStream( const Type& t, std::ostream& os ) { return os << std::quoted( toString( t ), '\'' ); }
41  } // namespace Interpolation
42 } // namespace GaudiMath
StatusCode parse_(ResultT &result, const std::string &input)
Definition: Factory.h:29
qi::rule< Iterator, ResultT(), Skipper > literal
STL class.
std::ostream & toStream(const Type &, std::ostream &)
StatusCode parse(Type &, const std::string &)
GaudiMath::Interpolation::Type ResultT
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
#define REGISTER_GRAMMAR(ResultType, GrammarName)
Definition: Grammars.h:70
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string toString(const Type &)