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

CdbBdbObjectTranslatorPT.hh

Go to the documentation of this file.
00001 #ifndef CDB_BDB_OBJECT_TRANSLATOR_PT_HH
00002 #define CDB_BDB_OBJECT_TRANSLATOR_PT_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbObjectTranslatorPT.hh,v 1.1 2005/05/03 21:15:14 gapon Exp $
00006 
00007 #include "BdbUtil/Bdb.hh"
00008 
00009 #include "CdbBase/CdbObjectTranslatorT.hh"
00010 
00011 #include <string>
00012 
00013 /// The transient & persistent type specific specialization of persistent-to-transient translators
00014 /**
00015   * This class is an element of the "persistent-to-transient" translation facility
00016   * extending the core CDB API and allowing a better (and more confined) controll
00017   * over persistency in client applications.
00018   *
00019   * Roles of this class are:
00020   *
00021   *   1. to translate an actual persistent type into its name
00022   *   2. to be a direct base class for concrete persistent-technology translators
00023   *
00024   * @see class CdbObjectTranslatorT
00025   */
00026 template< class P,
00027           class T >
00028 class CdbBdbObjectTranslatorPT : public CdbObjectTranslatorT<T> {
00029 
00030 private:
00031 
00032   /// Obtain a name of the current persistent type
00033   /**
00034     * IMPLEMENTATION NOTES:
00035     *
00036     *   1. This operation will crash if it will faild to get the type information!
00037     *
00038     *   2. The operation may start a short transaction of none is available yet.
00039     *      The transaction is needed to translate the specified persistent type into
00040     *      its name.
00041     */
00042     static std::string persistentType2Name( );
00043 
00044 private:
00045 
00046   /// Copy constructor (NOT IMPLEMENTED)
00047 
00048     CdbBdbObjectTranslatorPT( const CdbBdbObjectTranslatorPT<P,T>& );
00049 
00050   /// Assignment operator (NOT IMPLEMENTED)
00051 
00052     CdbBdbObjectTranslatorPT<P,T>& operator=( const CdbBdbObjectTranslatorPT<P,T>& );
00053 
00054 protected:
00055 
00056   /// Default constructor
00057   /**
00058     * IMPLEMENTATION NOTES:
00059     *
00060     *   The constructor may start a short transaction of none is available yet.
00061     *   The transaction is needed to translate the specified persistent type into
00062     *   its name.
00063     */
00064     CdbBdbObjectTranslatorPT(  );
00065 
00066 private:
00067 
00068   /// Translate into a transient object (transient type specific translation)
00069   /**
00070     * This method is implemented in terms of the redefined persistent type specific,
00071     * version which itself will have to be implemented by subclasses.
00072     *
00073     * DESIGN NOTE:
00074     *
00075     *   Note, that this method has moved into the "private" area to prevent
00076     *   it from being see by subclasses. Is this going to work w/o causing
00077     *   any compiler complains?
00078     *
00079     * @see CdbObjectTranslatorT::toTransientT()
00080     */
00081     virtual CdbStatus toTransientT( T*& theTransientPtr, /**< the pointer to be initialized with the result */
00082                                     const CdbObjectPtr& theObjectPtr     /**< the input metadata object */
00083                                   ) const;
00084 protected:
00085 
00086   /// Translate into a transient object (persistent & transient type specific translation)
00087   /**
00088     * This is a redefined version of a similar method CdbObjectTranslatorT::toTransientT()
00089     * defined in the base class and implemented above. Its role is to force translation
00090     * procedures of subclasses be written in terms of the specified persistent & transinet types.
00091     *
00092     * The method is supposed to be implemented by subclasses. The method is guaranteed
00093     * to be called with the correct parameters.
00094     *
00095     * @see CdbObjectTranslatorT::toTransientT()
00096     */
00097     virtual CdbStatus toTransientPT( T*&                 theTransientPtr,   /**< the pointer to be initialized with the result */
00098                                      const BdbHandle(P)& theObjectH         /**< the input persistent object */
00099                                    ) const = 0;
00100 public:
00101 
00102   /// Destructor
00103 
00104     virtual ~CdbBdbObjectTranslatorPT( ) { }
00105 };
00106 
00107 #ifdef    BABAR_COMP_INST
00108 #include "CdbBdb/CdbBdbObjectTranslatorPT.cc"
00109 #endif /* BABAR_COMP_INST */
00110 
00111 #endif  // CDB_BDB_OBJECT_TRANSLATOR_PT_HH

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