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

CdbBdbNTupleConversionImpl.hh

Go to the documentation of this file.
00001 #ifndef CDBBDBTABLE_NTUPLE_CONVERSION_IMPL_HH
00002 #define CDBBDBTABLE_NTUPLE_CONVERSION_IMPL_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbNTupleConversionImpl.hh,v 1.3 2004/04/02 07:48:56 gapon Exp $
00006 
00007 #include "BdbCond/BdbObject.hh"
00008 
00009 #include "CdbBase/CdbCPtr.hh"
00010 
00011 #include "CdbTable/CdbNTuple.hh"
00012 
00013 #include <string>
00014 
00015 /// The generic implementation of the conversion facility
00016 /**
00017   * IMPLEMENTATION NOTE:
00018   *
00019   *   The current implementation of this factory will support only predefined
00020   *   "primitive types" of elements. A mechanizm of expened support for arbitrary
00021   *   (or user defined) types of elements will be added later.
00022   *
00023   * USAGE NOTES:
00024   *
00025   *   Users are discouraged to use this API directly as its interface or
00026   *   implementation is likely to change. Another reason not to use this
00027   *   class is its "heavy" template interface.
00028   *
00029   *   The current package has a number of "fron-end" classes with more stable
00030   *   and much simple API.
00031   */
00032 template < class        T,
00033            unsigned int NCOL,
00034            class        ELEMENT_CONVERSION_RULES >
00035 class CdbBdbNTupleConversionImpl {
00036 
00037 public:
00038 
00039   /// Convert a persistent object to the transient form
00040   /**
00041     * If successuful, the method would initialize the smart pointer to point
00042     * onto a newely created transient table (of unspecified here actual implentation)
00043     * filled with data and metadata copied from the specified persistent table.
00044     *
00045     * If any kind of error will happen then the transient pointer is guaranteed
00046     * to stay intact.
00047     *
00048     * REQUIREMENTS:
00049     *
00050     * (1) The persistent table must have the same actual type and configurations
00051     *     (number of columns) as the transient one.
00052     *
00053     * (2) The corresponding vortual tables for the persistnt class must be
00054     *     properly loaded.
00055     *
00056     * (3) The type of elements of a persistent typle would be derived from
00057     *     the type converter policy supplied (or default) as a template parameter
00058     *     of the class.
00059     *
00060     * (4) Should the transient and persistent types of elements be different
00061     *     the corresponding conversion must exist and be provided through
00062     *     the supplied (or default) converter policy.
00063     */
00064     static CdbStatus to_transient( CdbCPtr< CdbNTuple< T, NCOL > >& thePtr,
00065                                    const ooRef(BdbObject)&          thePersRef );
00066 
00067   /// Convert a persistent object to the transient form (regular pointer version)
00068 
00069     static CdbStatus to_transient( CdbNTuple< T, NCOL >*&  thePtr,
00070                                    const ooRef(BdbObject)& thePersRef );
00071 
00072   /// Convert a transient object to the persistent form
00073   /**
00074     * If successuful, the method would initialize the persistent  reference to point
00075     * onto a newely created persistent table (of unspecified here actual implentation)
00076     * filled with data and metadata copied from the specified transient table.
00077     *
00078     * If any kind of error will happen then the persistent pointer is guaranteed
00079     * to stay intact.
00080     *
00081     * REQUIREMENTS:
00082     *
00083     * (1) The persistent table must have the same actual type and configurations
00084     *     (number of columns) as the transient one.
00085     *
00086     * (2) The corresponding vortual tables for the persistnt class must be
00087     *     properly loaded.
00088     *
00089     * (3) The type of elements of a persistent typle would be derived from
00090     *     the type converter policy supplied (or default) as a template parameter
00091     *     of the class.
00092     *
00093     * (4) Should the transient and persistent types of elements be different
00094     *     the corresponding conversion must exist and be provided through
00095     *     the supplied (or default) converter policy.
00096     */
00097     static CdbStatus to_persistent( ooRef(BdbObject)&                      thePersRef,
00098                                     const CdbCPtr< CdbNTuple< T, NCOL > >& thePtr,
00099                                     const BdbRefAny&                       theHintRef );
00100 };
00101 
00102 /// The (partialy) specialize version of the conversion facility for strings
00103 /**
00104   * This specialization is only meant to be used for n-tuples of strings.
00105   */
00106 template < unsigned int NCOL,
00107            class        ELEMENT_CONVERSION_RULES >
00108 class CdbBdbNTupleConversionImpl< std::string,
00109                                   NCOL,
00110                                   ELEMENT_CONVERSION_RULES > {
00111 
00112 public:
00113 
00114   /// Convert a persistent object to the transient form
00115   /**
00116     * @see CdbBdbNTupleConversionImpl::to_transient()
00117     */
00118     static CdbStatus to_transient( CdbCPtr< CdbNTuple< std::string, NCOL > >& thePtr,
00119                                    const ooRef(BdbObject)&                    thePersRef );
00120 
00121   /// Convert a persistent object to the transient form (regular pointer version)
00122 
00123     static CdbStatus to_transient( CdbNTuple< std::string, NCOL >*& thePtr,
00124                                    const ooRef(BdbObject)&          thePersRef );
00125 
00126   /// Convert a transient object to the persistent form
00127   /**
00128     * @see CdbBdbNTupleConversionImpl::to_transient()
00129     */
00130     static CdbStatus to_persistent( ooRef(BdbObject)&                                thePersRef,
00131                                     const CdbCPtr< CdbNTuple< std::string, NCOL > >& thePtr,
00132                                     const BdbRefAny&                                 theHintRef );
00133 };
00134 
00135 #ifdef     BABAR_COMP_INST
00136 #include "CdbBdbTable/CdbBdbNTupleConversionImpl.cc"
00137 #endif  // BABAR_COMP_INST
00138 
00139 #endif // CDBBDBTABLE_NTUPLE_CONVERSION_IMPL_HH
00140 

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