00001
00002
00003 #ifndef GAUDIUTILS_HISTOTABLEFORMAT_H
00004 #define GAUDIUTILS_HISTOTABLEFORMAT_H 1
00005
00006
00007
00008 #include "GaudiKernel/Kernel.h"
00009
00010
00011
00012 namespace AIDA
00013 {
00014 class IHistogram1D ;
00015 class IBaseHistogram ;
00016 }
00017
00018 namespace Gaudi
00019 {
00020 namespace Utils
00021 {
00022
00029 namespace Histos
00030 {
00031
00073 namespace Formats
00074 {
00075
00090 enum Format
00091 {
00092 Default = 0 ,
00093 Old ,
00094 Full ,
00095 FullStat ,
00096 Stat ,
00097 StatOnly ,
00098 Stat1 ,
00099 ShapeOnly ,
00100 Shape ,
00101 LineTitle ,
00102 LineOnly ,
00103 PathTitle
00104 } ;
00105
00113 GAUDI_API std::string format ( const int ID = Default ) ;
00114
00122 GAUDI_API std::string header ( const int ID = Default ) ;
00123
00124 }
00125
00130 GAUDI_API std::string path ( const AIDA::IBaseHistogram* aida ) ;
00131
00170 GAUDI_API std::string format
00171 ( const AIDA::IHistogram1D* histo ,
00172 const std::string& fmt ) ;
00173
00202 GAUDI_API std::string format
00203 ( const AIDA::IHistogram1D* histo ,
00204 const std::string& ID ,
00205 const std::string& fmt1 ,
00206 const std::string& fmt2 ) ;
00207
00231 template <class HISTO, class STREAM, class TERMINATOR>
00232 inline STREAM& printList
00233 ( HISTO first ,
00234 HISTO last ,
00235 const std::string& fmt ,
00236 STREAM& stream ,
00237 TERMINATOR term )
00238 {
00239 for ( ; first != last ; ++first )
00240 { stream << format ( *first , fmt ) << term ; }
00241 return stream ;
00242 }
00243
00267 template <class LIST, class STREAM, class TERMINATOR>
00268 inline STREAM& printList
00269 ( const LIST& histos ,
00270 const std::string& fmt ,
00271 STREAM& stream ,
00272 TERMINATOR term )
00273 {
00274 return printList
00275 ( histos.begin () , histos.end () , fmt , stream , term ) ;
00276 }
00277
00322 template <class HISTO, class STREAM, class TERMINATOR>
00323 inline STREAM& printMap
00324 ( HISTO begin ,
00325 HISTO end ,
00326 const std::string& fmt1 ,
00327 const std::string& fmt2 ,
00328 STREAM& stream ,
00329 TERMINATOR term )
00330 {
00331 for ( ; begin != end ; ++begin )
00332 {
00333 stream << format
00334 ( begin -> second ,
00335 begin -> first ,
00336 fmt1 , fmt2 ) << term ;
00337 }
00338 return stream ;
00339 }
00340
00383 template <class MAP, class STREAM, class TERMINATOR>
00384 inline STREAM& printMap
00385 ( const MAP& histos ,
00386 const std::string& fmt1 ,
00387 const std::string& fmt2 ,
00388 STREAM& stream ,
00389 TERMINATOR term )
00390 {
00391 return printMap
00392 ( histos.begin () , histos.end() , fmt1 , fmt2 , stream , term ) ;
00393 }
00394
00399 GAUDI_API std::string format
00400 ( const std::string& val1 ,
00401 const std::string& val2 ,
00402 const std::string& fmt ) ;
00403
00410
00411 class GAUDI_API Table
00412 {
00413 public:
00415 Table ( const int ID = 0 ) ;
00417 Table
00418 ( const std::string& format ,
00419 const std::string& header = "" ,
00420 const std::string& footer = "" ) ;
00421 public:
00422
00429 template <class HISTO, class STREAM, class TERMINATOR>
00430 STREAM& printList
00431 ( HISTO first ,
00432 HISTO last ,
00433 STREAM& stream ,
00434 TERMINATOR term ) const
00435 {
00436 if ( !header().empty() ) { stream << header () << term ; }
00437 Gaudi::Utils::Histos::printList ( first , last , format() , stream , term ) ;
00438 if ( !footer().empty() ) { stream << footer () << term ; }
00439 return stream ;
00440 }
00441
00442 public:
00455 template <class HISTO, class STREAM, class TERMINATOR>
00456 STREAM& printMap
00457 ( HISTO first ,
00458 HISTO last ,
00459 const std::string& fmt ,
00460 const std::string& hval ,
00461 STREAM& stream ,
00462 TERMINATOR term ) const
00463 {
00464 if ( !hval.empty() || !header().empty() )
00465 { stream << Gaudi::Utils::Histos::format ( hval , header() , fmt ) << term ; }
00466 return Gaudi::Utils::Histos::printMap
00467 ( first , last , fmt , format() , stream , term ) ;
00468 }
00469
00470 public:
00471
00473 const std::string& header () const { return m_header ; }
00474
00476 const std::string& footer () const { return m_footer ; }
00477
00479 const std::string& format () const { return m_format ; }
00480
00481 public:
00482
00484 void setHeader ( const std::string& v ) { m_header = v ; }
00485
00487 void setFooter ( const std::string& v ) { m_footer = v ; }
00488
00490 void setFormat ( const std::string& v ) { m_format = v ; }
00491
00492 public :
00493
00495 std::string toString ( const AIDA::IHistogram1D* histo ) const ;
00496
00497 public:
00498
00522 std::string toString
00523 ( const AIDA::IHistogram1D* histo ,
00524 const std::string& ID ,
00525 const std::string& fmt ) const ;
00526
00527 public:
00528
00529 std::string m_header ;
00530
00531 std::string m_footer ;
00532
00533 std::string m_format ;
00534
00535 } ;
00536 }
00537 }
00538 }
00539
00540
00541
00542 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
00543