00001 #ifndef CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_MRG_CONVERTER_HH 00002 #define CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_MRG_CONVERTER_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdb2RooPayloadMrgConverter.hh,v 1.3 2005/07/14 16:11:04 jtinslay Exp $ 00006 00007 #include "CdbRooConversionFwk/CdbBdb2RooPayloadConverter.hh" 00008 00009 #include <string> 00010 00011 /// The specialized generic "P-R" abstract base class for user defined (merging) converters 00012 /** 00013 * This base class allows to build "merging" converters which are supposed to construct 00014 * an output objects out of more than one input objects. Here is how to build 00015 * user defined converters based on this paradigme: 00016 * 00017 * 1. A user defined converter should derived from the current class 00018 * using the public inheritance. 00019 * 00020 * 2. The user defined converter should implement the "userDefinedConversion()" 00021 * conversion method re-defined below with an extended signature. 00022 * 00023 * 3. The list of extra objects passed to the conversion method will contain at 00024 * least one object. The actual number and types of objects will depend on 00025 * a use and on an implementation of a particular converter. 00026 */ 00027 template < class P, 00028 class R > 00029 class CdbBdb2RooPayloadMrgConverter : public CdbBdb2RooPayloadConverter<P,R> { 00030 00031 private: 00032 00033 /// A type of the converter 00034 /** 00035 * Implements the corresponding method defined by a base class or an interface. 00036 * 00037 * @see CdbRooConverterBase::mergingConverter() 00038 */ 00039 virtual bool mergingConverter( ) const { return true; }; 00040 00041 /// Implement a user-defined conversion 00042 /** 00043 * Implements the corresponding method defined by a base class or an interface. 00044 * 00045 * @see CdbBdb2RooPayloadConverter::userDefinedConversion() 00046 */ 00047 virtual CdbStatus userDefinedConversion( const BdbRef(BdbObject)& theInputObjectRef, 00048 R*& theOutputObjectPtr 00049 ) const; 00050 protected: 00051 00052 /// The default constructor 00053 /** 00054 * @see CdbBdb2RooPayloadConverter::CdbBdb2RooPayloadConverter() 00055 */ 00056 CdbBdb2RooPayloadMrgConverter( ); 00057 00058 /// The copy constructor 00059 00060 CdbBdb2RooPayloadMrgConverter( const CdbBdb2RooPayloadMrgConverter<P,R>& theOther ); 00061 00062 /// The assignment operator 00063 00064 CdbBdb2RooPayloadMrgConverter<P,R>& operator=( const CdbBdb2RooPayloadMrgConverter<P,R>& theOther ); 00065 00066 /// Implement a user-defined conversion (merged version) 00067 /** 00068 * This pure virtual method is supposed to be implemented by subclasses for 00069 * the specified (in the constructor) pair of classes. However, unlike its regular version 00070 * this one will also take a list of extra objects to be merged with the main input 00071 * object to produce an output object. The list is guranteed to have at least one extra object. 00072 * An actual number of extra objects depends on a particular use and an implementation of 00073 * a user defined converter. It's also defined during a database conversion planing. 00074 * 00075 * The method will be invoked by the above implemented "::userDefinedConversion()" method. 00076 * 00077 * The method is supposed to return CdbStatus::Success in case of its successfull 00078 * completion, or any other value otherwise, which will be treated as a failure. 00079 * Also when a call is successfull then the ouput object pointer must be filled with 00080 * a valid pointer onto a nely created object. 00081 * 00082 * NOTES: 00083 * 00084 * 1. The output object's ownership is also expected to be returned with the object. 00085 * 00086 * 2. The method has the same name as for the "one-to-one" conversion, but it has 00087 * a different signature. 00088 * 00089 * @see CdbBdb2RooPayloadMrgConverter::CdbBdb2RooPayloadMrgConverter() 00090 * @see CdbBdb2RooPayloadMrgConverter::userDefinedConversion() 00091 */ 00092 virtual CdbStatus userDefinedConversion( const BdbRef(BdbObject)& theMainInputObjectRef, 00093 const std::vector< BdbRef(BdbObject) >& theExtraObjectsList, 00094 R*& theOutputObjectPtr 00095 ) const = 0; 00096 public: 00097 00098 /// The destructor. 00099 00100 virtual ~CdbBdb2RooPayloadMrgConverter( ); 00101 }; 00102 00103 #ifdef BABAR_COMP_INST 00104 #include "CdbRooConversionFwk/CdbBdb2RooPayloadMrgConverter.cc" 00105 #endif // BABAR_COMP_INST 00106 00107 #endif // CDBROOCONVERSIONFWK_BDB_2_ROO_PAYLOAD_MRG_CONVERTER_HH
1.3-rc3