Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbNTuplePrint.hh

Go to the documentation of this file.
00001 #ifndef CDB_NTUPLE_PRINT_HH
00002 #define CDB_NTUPLE_PRINT_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbNTuplePrint.hh,v 1.4 2004/08/06 05:54:41 bartoldu Exp $
00006 
00007 #include "CdbBase/CdbCPtr.hh"
00008 
00009 #include "CdbTable/CdbNTuplePrintDefaultConverter.hh"
00010 #include "CdbTable/CdbNTuplePrintTypes.hh"
00011 #include "CdbTable/CdbNTuplePrintImpl.hh"
00012 
00013 #include <iostream>
00014 
00015 /// A trivial class used to turn on the default element conversion rules
00016 /**
00017   * This class is used to turn on default output conversion for n-tuple elements
00018   * if a client's code chooses so when using the "easy print" fron-end tool
00019   * defined below.
00020   *
00021   * The default converter assumes that there is the "operator<<" operator defined for
00022   * a type of n-tuple elements.
00023   *
00024   * Note, this is an internal class, which is not supposed to be used directly by
00025   * a client code.
00026   *
00027   * @see class CdbNTuplePrintConverter_Default
00028   */
00029 class CdbNTuplePrintConverter_UseDefault {
00030 };
00031 
00032 /// An "easy print" front-end interface to the printing facility
00033 /**
00034   * This interface would retrieve a configuration of a tuple from its
00035   * pointer's type, thus eliminating a need to pass them (the configuration
00036   * parameters).
00037   */
00038 template < class CONVERTER = CdbNTuplePrintConverter_UseDefault >
00039 class CdbNTuplePrint {
00040 
00041 public:
00042 
00043   /// The print method (full control over parameters, Standard Output Stream)
00044 
00045     template < class NTUPLE >
00046     static CdbStatus print( const CdbCPtr<NTUPLE>&                  thePtr,
00047                             const unsigned int                      theColumnWidth,
00048                             const char*                             theIndent,
00049                             const CdbNTuplePrintTypes::FrameType    theFrameType,
00050                             const CdbNTuplePrintTypes::FrameBorders theFrameBorders )
00051     {
00052         return CdbNTuplePrintImpl< NTUPLE, CONVERTER >::print( std::cout,
00053                                                                thePtr,
00054                                                                theColumnWidth,
00055                                                                theIndent,
00056                                                                theFrameType,
00057                                                                theFrameBorders );
00058     }
00059 
00060   /// The print method (full control over parameters, any output stream)
00061 
00062     template < class NTUPLE >
00063     static CdbStatus print( std::ostream&                                theOutputStream,
00064                             const CdbCPtr<NTUPLE>&                  thePtr,
00065                             const unsigned int                      theColumnWidth,
00066                             const char*                             theIndent,
00067                             const CdbNTuplePrintTypes::FrameType    theFrameType,
00068                             const CdbNTuplePrintTypes::FrameBorders theFrameBorders )
00069     {
00070         return CdbNTuplePrintImpl< NTUPLE, CONVERTER >::print( theOutputStream,
00071                                                                thePtr,
00072                                                                theColumnWidth,
00073                                                                theIndent,
00074                                                                theFrameType,
00075                                                                theFrameBorders );
00076     }
00077 
00078   /// A simple method of printing #1 (preselected set of parameters, Standard Output Stream)
00079 
00080     template < class NTUPLE >
00081     static CdbStatus print1( const CdbCPtr<NTUPLE>& thePtr,
00082                              const unsigned int     theColumnWidth = 12 )
00083     {
00084         return print( thePtr,
00085                       theColumnWidth,
00086                       "  ",
00087                       CdbNTuplePrintTypes::ClosedFrame,
00088                       CdbNTuplePrintTypes::DoubleHashes );
00089     }
00090 
00091   /// A simple method of printing #1 (preselected set of parameters, any output stream)
00092 
00093     template < class NTUPLE >
00094     static CdbStatus print1( std::ostream&               theOutputStream,
00095                              const CdbCPtr<NTUPLE>& thePtr,
00096                              const unsigned int     theColumnWidth = 12 )
00097     {
00098         return print( theOutputStream,
00099                       thePtr,
00100                       theColumnWidth,
00101                       "  ",
00102                       CdbNTuplePrintTypes::ClosedFrame,
00103                       CdbNTuplePrintTypes::DoubleHashes );
00104     }
00105 
00106   /// A simple method of printing #2 (preselected set of parameters, Standard Output Stream)
00107 
00108     template < class NTUPLE >
00109     static CdbStatus print2( const CdbCPtr<NTUPLE>& thePtr,
00110                              const unsigned int     theColumnWidth = 12 )
00111     {
00112         return print( thePtr,
00113                       theColumnWidth,
00114                       "  ",
00115                       CdbNTuplePrintTypes::OpenFrame,
00116                       CdbNTuplePrintTypes::SingleXes );
00117     }
00118 
00119   /// A simple method of printing #2 (preselected set of parameters, any output stream)
00120 
00121     template < class NTUPLE >
00122     static CdbStatus print2( std::ostream&               theOutputStream,
00123                              const CdbCPtr<NTUPLE>& thePtr,
00124                              const unsigned int     theColumnWidth = 12 )
00125     {
00126         return print( theOutputStream,
00127                       thePtr,
00128                       theColumnWidth,
00129                       "  ",
00130                       CdbNTuplePrintTypes::OpenFrame,
00131                       CdbNTuplePrintTypes::SingleXes );
00132     }
00133 };
00134 
00135 /// The full specialization for the "easy print" fron-end defined above
00136 /**
00137   * Unlike its generic couterpart, this specialized version of the class would
00138   * rely on the default conversion rules for n-tuple elements.
00139   *
00140   * @see class CdbNTuplePrintDefaultConverter
00141   */
00142 template < >
00143 class CdbNTuplePrint< CdbNTuplePrintConverter_UseDefault > {
00144 
00145 public:
00146 
00147     template < class NTUPLE >
00148     static CdbStatus print( const CdbCPtr<NTUPLE>&                  thePtr,
00149                             const unsigned int                      theColumnWidth,
00150                             const char*                             theIndent,
00151                             const CdbNTuplePrintTypes::FrameType    theFrameType,
00152                             const CdbNTuplePrintTypes::FrameBorders theFrameBorders )
00153     {
00154         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print( std::cout,
00155                                                                                                          thePtr,
00156                                                                                                          theColumnWidth,
00157                                                                                                          theIndent,
00158                                                                                                          theFrameType,
00159                                                                                                          theFrameBorders );
00160     }
00161 
00162     template < class NTUPLE >
00163     static CdbStatus print( std::ostream&                                theOutputStream,
00164                             const CdbCPtr<NTUPLE>&                  thePtr,
00165                             const unsigned int                      theColumnWidth,
00166                             const char*                             theIndent,
00167                             const CdbNTuplePrintTypes::FrameType    theFrameType,
00168                             const CdbNTuplePrintTypes::FrameBorders theFrameBorders )
00169     {
00170         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print( theOutputStream,
00171                                                                                                          thePtr,
00172                                                                                                          theColumnWidth,
00173                                                                                                          theIndent,
00174                                                                                                          theFrameType,
00175                                                                                                          theFrameBorders );
00176     }
00177 
00178     template < class NTUPLE >
00179     static CdbStatus print1( const CdbCPtr<NTUPLE>& thePtr,
00180                              const unsigned int     theColumnWidth = 12 )
00181     {
00182         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print1( thePtr,
00183                                                                                                           theColumnWidth );
00184     }
00185 
00186     template < class NTUPLE >
00187     static CdbStatus print1( std::ostream&               theOutputStream,
00188                              const CdbCPtr<NTUPLE>& thePtr,
00189                              const unsigned int     theColumnWidth = 12 )
00190     {
00191         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print1( theOutputStream,
00192                                                                                                           thePtr,
00193                                                                                                           theColumnWidth );
00194     }
00195 
00196     template < class NTUPLE >
00197     static CdbStatus print2( const CdbCPtr<NTUPLE>& thePtr,
00198                              const unsigned int     theColumnWidth = 12 )
00199     {
00200         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print2( thePtr,
00201                                                                                                           theColumnWidth );
00202     }
00203 
00204     template < class NTUPLE >
00205     static CdbStatus print2( std::ostream&               theOutputStream,
00206                              const CdbCPtr<NTUPLE>& thePtr,
00207                              const unsigned int     theColumnWidth = 12 )
00208     {
00209         return CdbNTuplePrint< CdbNTuplePrintDefaultConverter< typename NTUPLE::element_type > >::print2( theOutputStream,
00210                                                                                                           thePtr,
00211                                                                                                           theColumnWidth );
00212     }
00213 };
00214 
00215 #endif // CDB_NTUPLE_PRINT_HH
00216 

Generated on Mon Dec 5 18:22:07 2005 for CDB by doxygen1.3-rc3