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

CdbRooConverterBase.hh

Go to the documentation of this file.
00001 #ifndef CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_CONVERTER_BASE_HH
00002 #define CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_CONVERTER_BASE_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbRooConverterBase.hh,v 1.1 2005/07/14 16:11:04 jtinslay Exp $
00006 
00007 #include "CdbBase/CdbCPtr.hh"
00008 
00009 #include "CdbRoo/CdbRooObjectR.hh"
00010 
00011 #include "BdbCond/BdbObject.hh"
00012 
00013 #include <string>
00014 #include <vector>
00015 
00016 class TTree;
00017 class TBranch;
00018 
00019 /// The abstract base class for user defined convertor classes
00020 /**
00021   * More details...
00022   */
00023 class CdbRooConverterBase {
00024 
00025 private:
00026 
00027   /// The default constructor (NOT IMPLEMENTED)
00028   /**
00029     * It just doesn't make a sense in the current context not to know names
00030     * of persistent classes.
00031     */
00032     CdbRooConverterBase( );
00033 
00034 protected:
00035 
00036   /// The normal constructor.
00037   /**
00038     * Is used to cache the names of input and output classes.
00039     *
00040     * DESIGN NOTE:
00041     *
00042     *   Note, that for the sake of consistency of this class's design the constructor
00043     *   (as well as other forms of constructing or loading the current context) is only
00044     *   available to subclasses.
00045     */
00046     CdbRooConverterBase( const std::string& theInputClassName,
00047                                     const std::string& theOutputClassName
00048                                   );
00049 
00050   /// The copy constructor
00051 
00052     CdbRooConverterBase( const CdbRooConverterBase& theOther );
00053 
00054   /// The assignment operator
00055 
00056     CdbRooConverterBase& operator=( const CdbRooConverterBase& theOther );
00057 
00058 public:
00059 
00060   /// The destructor.
00061 
00062     virtual ~CdbRooConverterBase( );
00063 
00064   /// The input class name
00065 
00066     const std::string& inputClassName( ) const { return _inputClassName; }
00067 
00068   /// The input class name
00069 
00070     const std::string& outputClassName( ) const { return _outputClassName; }
00071 
00072   /// A wrapper method for the conversion operation
00073   /**
00074     * This is the method to be called to initiate the actual conversion. The method
00075     * will evaluate the final type of the input object to make sure that it matches
00076     * the one specified in the constructor before calling a user implemented
00077     * conversion sequence. It will also make sure that a type of an output object
00078     * produced by the user defined conversion sequence matches the one specified
00079     * in the constructor.
00080     *
00081     * A valid non-zero persistent reference is expected as an input object.
00082     *
00083     * The method also has a list of "extra" objects to be used in addition to
00084     * the input object to produce the output one. The list can be empty. Also see notes
00085     * on the converter's type as it's defined by the CdbRooConverterBase::mergingConverter()
00086     * method defined below.
00087     *
00088     * The method would return CdbStatus::Success in case of its successfull completion,
00089     * or CdbStatus::IllegalParameters in case of the type mismatch (on either step),
00090     * or a error status returned by te user defined sequence.
00091     *
00092     * The method is supposed to be implemented by a subclass where an actual persistent
00093     * type is known at a compilation time.
00094     *
00095     * @see CdbRooConverterBase::CdbRooConverterBase()
00096     * @see CdbRooConverterBase::mergingConverter()
00097     */
00098     virtual CdbStatus conversion( const BdbRef(BdbObject)&                theInputObjectRef,
00099                                   const std::vector< BdbRef(BdbObject) >& theExtraObjectsList
00100                                 ) = 0;
00101 
00102   /// A type of the converter
00103   /**
00104     * The true value returned by the method means that a list of extra objects
00105     * passed down to the CdbRooConverterBase::conversion() method shouldn't
00106     * be empty. Otherwise the CdbStatus::IllegalParameters method is returned
00107     * by the conversion method.
00108     *
00109     * If the returned value is false then it's all opposite - the list must be empty.
00110     * Otherwise the CdbStatus::Error method is returned by the conversion method.
00111     *
00112     * The default value type of the converter doesn't allow merging multiple input
00113     * objects. This behavior can be overriden by subclasses.
00114     *
00115     * @see CdbRooConverterBase::conversion()
00116     */
00117     virtual bool mergingConverter( ) const { return false; };
00118 
00119   /// Create a new branch with specified parameters
00120   /**
00121     * This operation is put here to let the conversion framework an access to a mechanics
00122     * of the TTree/TBranch. This mechanics had to be moved into this hierarchy
00123     * because of a change in the public interface of the TTree class in between
00124     * the following versions of ROOT:
00125     *
00126     *   4.02/00
00127     *   4.03/02
00128     *
00129     * As of the version "4.03/02" of ROOT's TTree the branch constructor expects an exact
00130     * type of objects to be stored in the branch.
00131     *
00132     * The method is supposed to be implemented by a subclass where an actual persistent
00133     * type is known at a compilation time.
00134     */
00135     virtual TBranch* branchConstructor( TTree&      theTree,
00136                                         const char* theBranchName ) = 0;
00137 
00138 private:
00139 
00140     std::string _inputClassName;
00141     std::string _outputClassName;
00142 };
00143 
00144 #endif  // CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_CONVERTER_BASE_HH

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