The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
AxisAsProperty.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11
12// cppcheck-suppress-file useInitializationList; for consistency
13
14#pragma once
15
17
20
21#if ( BOOST_VERSION >= 187000 ) && ( BOOST_VERSION < 188000 )
22# define BOOST_ALLOW_DEPRECATED_HEADERS
23#endif
24#include <boost/spirit/include/qi.hpp>
25#undef BOOST_ALLOW_DEPRECATED_HEADERS
26
36namespace Gaudi {
37 namespace Parsers {
38
39 namespace qi = boost::spirit::qi;
40
41 template <typename Iterator, typename Skipper, typename Arithmetic>
42 struct AxisGrammar : qi::grammar<Iterator, Gaudi::Accumulators::Axis<Arithmetic>(), qi::locals<char>, Skipper> {
44 struct StoreNbinsOp {
45 void operator()( Axis& res, unsigned int const& nBins ) const { res.setNumBins( nBins ); }
46 };
48 void operator()( Axis& res, Arithmetic const& minValue ) const { res.setMinValue( minValue ); }
49 };
51 void operator()( Axis& res, Arithmetic const& maxValue ) const { res.setMaxValue( maxValue ); }
52 };
53 struct StoreTitleOp {
54 void operator()( Axis& res, std::string const& title ) const { res.setTitle( title ); }
55 };
56 AxisGrammar() : AxisGrammar::base_type( axis ) {
57 begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')'];
58 end = enc::char_( qi::_r1 );
59 core = qi::int_[storeNbins( qi::_val, qi::_1 )] >> "," >> qi::double_[storeMinValue( qi::_val, qi::_1 )] >>
60 "," >> qi::double_[storeMaxValue( qi::_val, qi::_1 )] >>
61 -( "," >> title[storeTitle( qi::_val, qi::_1 )] );
62 axis = begin[qi::_a = qi::_1] >> core[qi::_val = qi::_1] >> end( qi::_a );
63 }
64 qi::rule<Iterator, Axis(), qi::locals<char>, Skipper> axis;
65 qi::rule<Iterator, Axis(), Skipper> core;
66 qi::rule<Iterator, char()> begin;
67 qi::rule<Iterator, void( char )> end;
69 ph::function<StoreNbinsOp> storeNbins;
70 ph::function<StoreMinValueOp> storeMinValue;
71 ph::function<StoreMaxValueOp> storeMaxValue;
72 ph::function<StoreTitleOp> storeTitle;
73 };
74
75 template <typename Iterator, typename Skipper, typename Arithmetic>
79
80 // Parse function... nothing special, but it must be done explicitely.
81 template <typename Arithmetic>
82 StatusCode parse( Gaudi::Accumulators::Axis<Arithmetic>& result, const std::string& input ) {
83 return parse_( result, input );
84 }
85
86 } // namespace Parsers
87
88} // namespace Gaudi
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition Iterator.h:18
implementation of various functions for streaming.
Definition of a default type of Histogram Axis It contains number of bins, min and max value plus a t...
void setMinValue(Arithmetic v)
void setMaxValue(Arithmetic v)
void setNumBins(unsigned int n)
void setTitle(std::string const &t)
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
SkipperGrammar< IteratorT > Skipper
Definition Factory.h:24
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
StatusCode parse_(ResultT &result, std::string_view input)
Definition Factory.h:26
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
void operator()(Axis &res, Arithmetic const &maxValue) const
void operator()(Axis &res, Arithmetic const &minValue) const
void operator()(Axis &res, unsigned int const &nBins) const
void operator()(Axis &res, std::string const &title) const
ph::function< StoreNbinsOp > storeNbins
StringGrammar< Iterator, Skipper > title
ph::function< StoreTitleOp > storeTitle
ph::function< StoreMaxValueOp > storeMaxValue
ph::function< StoreMinValueOp > storeMinValue
qi::rule< Iterator, char()> begin
qi::rule< Iterator, Axis(), Skipper > core
Gaudi::Accumulators::Axis< Arithmetic > Axis
qi::rule< Iterator, void(char)> end
qi::rule< Iterator, Axis(), qi::locals< char >, Skipper > axis