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

CdbRooNTupleConversionRules.hh

Go to the documentation of this file.
00001 #ifndef CDBROOTABLE_NTUPLE_CONVERSION_RULES_HH
00002 #define CDBROOTABLE_NTUPLE_CONVERSION_RULES_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbRooNTupleConversionRules.hh,v 1.3 2005/01/13 15:04:44 gapon Exp $
00006 
00007 #include <Rtypes.h>   // to bring in ROOT I/O data types
00008 
00009 #include "CdbBase/CdbCommon.hh"
00010 
00011 #include <string>
00012 
00013 /// The default "persistent/transient" conversion rules for elements of tuples
00014 /**
00015   * This pseudo-converter can be applied for any types of elements. This converter
00016   * is used by default when converting tuples between the transient and persistent
00017   * forms.
00018   *
00019   * The only template parameter of the class is a transient type of elements.
00020   *
00021   * There is also a number of specializations of the facility (see below). They'll
00022   * be used for types requiering nono-trivial conversion or because of lack of
00023   * implicit conversion supplied with the compiler or user classes.
00024   */
00025 template < class T >
00026 struct CdbRooNTupleConversionRules_Default {
00027 
00028     typedef T Transient;
00029     typedef T Persistent;
00030 
00031     static const Persistent& to_persistent( const Transient&  value ) { return value; }
00032     static const Transient&  to_transient ( const Persistent& value ) { return value; }
00033 };
00034 
00035 /// The default "persistent/transient" conversion rules for elements of tuples (complementary)
00036 /**
00037   * This is a complementary facility whose template parameter is a persistent type of elements.
00038   * This class can be used to derive a persistent type for the specified persistent one,
00039   * when when the actual transient type is not known.
00040   *
00041   * The specializations are also available.
00042   */
00043 template < class P >
00044 struct CdbRooNTupleConversionReverseRules_Default {
00045 
00046     typedef P Transient;
00047     typedef P Persistent;
00048 
00049     static const Persistent& to_persistent( const Transient&  value ) { return value; }
00050     static const Transient&  to_transient ( const Persistent& value ) { return value; }
00051 };
00052 
00053 /// The specialization for platform dependent "long" type of C++
00054 /**
00055   * According to ROOT I/O documentation (see the "Rtypes.h" header file) the "long" time
00056   * is not portable one. Foe example it translates as 32 bit integer on all platforms
00057   * except DEC Alpha. And it's 64 bit integer on DEC Alpha.
00058   *
00059   * In GNU C++ compiler (at least before and including 2.95.3) the 'long' is typedef-ed
00060   * as 'long int',
00061   *
00062   * SOLUTION: Map C++ 'long' into a portable 'Long64_t', which has 64-bits in its width.
00063   */
00064 /*
00065  * ATTENTION: This type does not seem to be supprted by ROOT I/O.
00066  *
00067 template <>
00068 struct CdbRooNTupleConversionRules_Default<long> {
00069 
00070     typedef long     Transient;
00071     typedef Long64_t Persistent;
00072 
00073     static const Persistent to_persistent( const Transient&  value ) { return (Persistent)value; }
00074     static const Transient  to_transient ( const Persistent& value ) { return (Transient)value; }
00075 };
00076 template <>
00077 struct CdbRooNTupleConversionReverseRules_Default<Long64_t> {
00078 
00079     typedef long     Transient;
00080     typedef Long64_t Persistent;
00081 
00082     static const Persistent to_persistent( const Transient&  value ) { return (Persistent)value; }
00083     static const Transient  to_transient ( const Persistent& value ) { return (Transient)value; }
00084 };
00085 */
00086 
00087 /// The specialization for platform dependent "unsigned long" type of C++
00088 /**
00089   * @see class CdbRooNTupleConversionRules_Default<long>
00090   */
00091 /*
00092  * ATTENTION: This type does not seem to be supprted by ROOT I/O.
00093  *
00094 template <>
00095 struct CdbRooNTupleConversionRules_Default<unsigned long> {
00096 
00097     typedef unsigned long Transient;
00098     typedef ULong64_t     Persistent;
00099 
00100     static const Persistent to_persistent( const Transient&  value ) { return (Persistent)value; }
00101     static const Transient  to_transient ( const Persistent& value ) { return (Transient)value; }
00102 };
00103 template <>
00104 struct CdbRooNTupleConversionReverseRules_Default<ULong64_t> {
00105 
00106     typedef unsigned long Transient;
00107     typedef ULong64_t     Persistent;
00108 
00109     static const Persistent to_persistent( const Transient&  value ) { return (Persistent)value; }
00110     static const Transient  to_transient ( const Persistent& value ) { return (Transient)value; }
00111 };
00112 */
00113 
00114 /// The non-trivial "persistent/transient" converter for elements of tuples
00115 /**
00116   * This converter will use type cast operator to convert values of elements.
00117   */
00118 template < class T,
00119            class P >
00120 struct CdbRooNTupleConversionRules_Explicit {
00121 
00122     typedef T Transient;
00123     typedef P Persistent;
00124 
00125     static Persistent to_persistent( const Transient&  value ) { return (Persistent)value; }
00126     static Transient  to_transient ( const Persistent& value ) { return (Transient)value; }
00127 };
00128 
00129 /// A trivial class used to turn on the default element conversion rules
00130 
00131 class CdbRooNTupleConversionRules_UseDefault {
00132 };
00133 
00134 #endif // CDBROOTABLE_NTUPLE_CONVERSION_RULES_HH
00135 

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