00001
00002
00003
00004
00005
00006
00007 #include "GaudiKernel/HistoDef.h"
00008 #include "GaudiKernel/HistoProperty.h"
00009
00010
00011
00012 #include "GaudiKernel/Parsers.icpp"
00013
00020
00021 namespace Gaudi
00022 {
00023 namespace Parsers
00024 {
00025
00044 class Histo1DGrammar
00045 : public grammar<Histo1DGrammar,
00046 ClosureGrammar<Gaudi::Histo1DDef>::context_t>
00047 {
00048 public:
00049
00050 typedef Gaudi::Histo1DDef ResultT;
00051 public:
00053 void matchLow ( const double low ) const
00054 { this -> val() . setLowEdge ( low ) ; }
00055 void matchHigh ( const double high ) const
00056 { this -> val() . setHighEdge ( high ) ; }
00057 void matchTitle ( const std::string& title ) const
00058 { this -> val() . setTitle ( title ) ; }
00059 void matchBins ( const int bins ) const
00060 { this -> val() . setBins ( bins ) ; }
00061 public:
00062 template <typename ScannerT>
00063 struct definition
00064 {
00065 typedef Gaudi::Parsers::Histo1DGrammar H1G;
00066 definition( H1G const &self)
00067 {
00068 val1 = sG [boost::bind(&H1G::matchTitle , &self , _1 ) ]
00069 >> "," >> rG [boost::bind(&H1G::matchLow , &self , _1 ) ]
00070 >> "," >> rG [boost::bind(&H1G::matchHigh , &self , _1 ) ]
00071 >> !( "," >> iG [boost::bind(&H1G::matchBins , &self , _1 ) ] ) ;
00072
00073 val2 = rG [boost::bind(&H1G::matchLow , &self , _1 ) ]
00074 >> "," >> rG [boost::bind(&H1G::matchHigh , &self , _1 ) ]
00075 >> "," >> sG [boost::bind(&H1G::matchTitle , &self , _1 ) ]
00076 >> !( "," >> iG [boost::bind(&H1G::matchBins , &self , _1 ) ] ) ;
00077
00078 val3 = rG [boost::bind(&H1G::matchLow , &self , _1 ) ]
00079 >> "," >> rG [boost::bind(&H1G::matchHigh , &self , _1 ) ]
00080 >> !( "," >> iG [boost::bind(&H1G::matchBins , &self , _1 ) ] )
00081 >> !( "," >> sG [boost::bind(&H1G::matchTitle , &self , _1 ) ] ) ;
00082
00083 histogram = "(" >> ( val1 || val2 || val3 ) >> ")";
00084 }
00085 RealGrammar<> rG ;
00086 IntGrammar<> iG ;
00087 StringGrammar sG ;
00088 boost::spirit::rule<ScannerT> const& start() const { return histogram;}
00089 rule<ScannerT> histogram ;
00090 rule<ScannerT> val1,val2,val3 ;
00091 };
00092 };
00093 }
00094 }
00095
00096
00097
00098
00099
00100
00101
00102 StatusCode Gaudi::Parsers::parse
00103 ( Gaudi::Histo1DDef& histo ,
00104 const std::string& input )
00105 {
00106 Histo1DGrammar g;
00107 const bool full =
00108 boost::spirit::parse
00109 ( createIterator(input),
00110 IteratorT(),
00111 g[var(histo)=arg1],
00112 SkipperGrammar()).full;
00113
00114 return full && histo.ok() ? StatusCode::SUCCESS : StatusCode::FAILURE ;
00115 }
00116
00125
00126 StatusCode Gaudi::Parsers::parse
00127 ( std::map<std::string,Gaudi::Histo1DDef>& histos ,
00128 const std::string& input )
00129 {
00130 MapGrammar<StringGrammar,Histo1DGrammar> g;
00131 const bool full = boost::spirit::parse
00132 ( createIterator(input),
00133 IteratorT() ,
00134 g[var(histos)=arg1],
00135 SkipperGrammar() ).full;
00136
00137 if ( !full ) { return StatusCode::FAILURE ; }
00138
00139 for ( std::map<std::string,Gaudi::Histo1DDef>::const_iterator
00140 ih = histos.begin() ; histos.end() != ih ; ++ih )
00141 { if ( !ih->second.ok() ) { return StatusCode::FAILURE ; } }
00142
00143 return StatusCode::SUCCESS ;
00144 }
00145
00146
00147
00148
00149