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

CdbBdbProxyBase.hh

Go to the documentation of this file.
00001 #ifndef CDBBDB_PROXY_BASE_HH
00002 #define CDBBDB_PROXY_BASE_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbProxyBase.hh,v 1.12 2005/07/12 21:29:18 jtinslay Exp $
00006 
00007 #include "CdbBdb/CdbBdbProxyCache.hh"
00008 #include "ProxyDict/IfdDataProxyTemplate.hh"
00009 
00010 class BdbCondDefStrategy;
00011 
00012 #include <memory>
00013 #include <vector>
00014 
00015 /// This class represents a base class for the Condition/DB proxies
00016 /**
00017   * The class is meant to be derived by every single proxy loading persistent objects
00018   * from the Condition/DB. The roles of the class are:
00019   *
00020   * - takes respon
00021   */
00022 template< class T >
00023 class CdbBdbProxyBase : public IfdDataProxyTemplate<T>,
00024                         public CdbBdbProxyCache {
00025 
00026 private:
00027 
00028   /// The copy constructor (NOT IMPLEMENTED)
00029   /**
00030     * More details...
00031     */
00032     CdbBdbProxyBase( const CdbBdbProxyBase<T>& );
00033 
00034   /// The asignment operator (NOT IMPLEMENTED)
00035   /**
00036     * More details...
00037     */
00038     CdbBdbProxyBase<T>& operator=( const CdbBdbProxyBase<T>& );
00039 
00040 public:
00041 
00042   /// The normal and default constructor
00043   /**
00044     * The only optional argument of the constructor takes the strategy object
00045     * for locating GenEnv parameters. If 0 pointer is passed then a default
00046     * strategy will be enforced.
00047     *
00048     * Note, that the ownreship of the strategy object is also passed to the constructor.
00049     */
00050     explicit CdbBdbProxyBase( BdbCondDefStrategy* theStrategy = 0 );
00051 
00052   /// The destructor
00053 
00054     virtual ~CdbBdbProxyBase( );
00055 
00056   /// The ProxyDict fault handler
00057   /**
00058     * This method implements the corresponding method defined at the base class
00059     * or an interface.
00060     */
00061     virtual T* faultHandler( IfdProxyDict* theDict,
00062                              const IfdKey& theKey,
00063                              AbsArg&       theArg );
00064 
00065   /// The ProxyDict store handler
00066   /**
00067     * This method implements the corresponding method defined at the base class
00068     * or an interface.
00069     */
00070     virtual void storeHandler( IfdProxyDict* theDict,
00071                                const IfdKey& theKey,
00072                                AbsArg&       theArg,
00073                                T*            theObject );
00074 
00075   /// The ProxyDict cache tester
00076   /**
00077     * This method implements the corresponding method defined at the base class
00078     * or an interface.
00079     */
00080     virtual void testCache( );
00081 
00082 protected:
00083 
00084   /// The redefined fault handler
00085   /**
00086     * This method is to be implemented by derived classes. It does the actuall
00087     * job of constructing the transient product of the corresponding proxy.
00088     *
00089     * The method is called whenever the persistent cache of the current class is reloaded.
00090     */
00091     virtual T* redefinedFaultHandler( const std::vector<CdbBdbProxyElement>& theListOfElements ) = 0;
00092 
00093   /// Return another time to try instead of original one.
00094   /**
00095     *  This method is called whenever redefinedFaultHandler return zero pointer.
00096     *  If this function retuns true then the algorithm repeats with the different
00097     *  time returned in the anotherTime parameter. Default implementation in this
00098     *  class always returns false.
00099     */
00100     virtual bool tryAnotherTime( const BdbTime&                         theOriginalTime, 
00101                                  const std::vector<CdbBdbProxyElement>& theListOfElements,
00102                                  BdbTime&                               TheOtherTime ) ;
00103 
00104   /// Allow access to the cached transient
00105 
00106     T* transientCache( ) { return _transient.get( ); }
00107 
00108   /// Modify the cached transient
00109 
00110     void setTransientCache( T* theNewTransientPtr ) { _transient.reset( theNewTransientPtr ); }
00111 
00112   /// Allow access to the current fault time
00113 
00114     BdbTime faultTime( ) const;
00115 
00116   /// Invalidate the transiniet cache of the proxy
00117 
00118     void invalidateTransientCache( ) { setTransientCache( 0 ); }
00119 
00120   /// Access strategy object
00121 
00122     const BdbCondDefStrategy* strategy( ) const { return _strategy.get( ); }
00123 
00124   /// Modify the strategy object
00125 
00126     void setStrategy( BdbCondDefStrategy* theNewStrategyPtr ) { _strategy.reset( theNewStrategyPtr ); }
00127 
00128 private:
00129 
00130   // The strategy
00131 
00132     std::auto_ptr<BdbCondDefStrategy> _strategy;
00133 
00134   // The transient cache
00135 
00136     std::auto_ptr<T> _transient;
00137     friend class CdbRTestUtility;
00138 };
00139 
00140 /// This class specializes a base class for the Condition/DB proxies
00141 /**
00142   * This specialized version of the proxy base class can be used when
00143   * condition objects are fetched from the CDB using an explicitly specified
00144   * revision name and partition identifier rather than relying on configurations
00145   * of condityions in teh current view.
00146   *
00147   * @see CdbBdbProxyBase
00148   */
00149 template< class T >
00150 class CdbBdbProxyBaseUsingRevision : public CdbBdbProxyBase<T> {
00151 
00152 private:
00153 
00154   /// The default constructor (NOT IMPLEMENTED)
00155   /**
00156     * More details...
00157     */
00158     CdbBdbProxyBaseUsingRevision( );
00159 
00160   /// The copy constructor (NOT IMPLEMENTED)
00161   /**
00162     * More details...
00163     */
00164     CdbBdbProxyBaseUsingRevision( const CdbBdbProxyBaseUsingRevision<T>& );
00165 
00166   /// The asignment operator (NOT IMPLEMENTED)
00167   /**
00168     * More details...
00169     */
00170     CdbBdbProxyBaseUsingRevision<T>& operator=( const CdbBdbProxyBaseUsingRevision<T>& );
00171 
00172 public:
00173 
00174   /// The normal constructor
00175   /**
00176     * A revision to be used by the proxy when finding persistent objects is specified
00177     * by its name in a scope of a partition. Note, that for the regular conditions
00178     * the partition identifier is always 0.
00179     *
00180     * The last optional argument of the constructor takes the strategy object
00181     * for locating GenEnv parameters. If 0 pointer is passed then a default
00182     * strategy will be enforced.
00183     *
00184     * Note, that the ownreship of the strategy object is also passed to the constructor.
00185     */
00186     explicit CdbBdbProxyBaseUsingRevision( const std::string&  theRevisionName,
00187                                            unsigned int        thePartitionId = 0,
00188                                            BdbCondDefStrategy* theStrategy    = 0 );
00189 
00190   /// The destructor
00191 
00192     virtual ~CdbBdbProxyBaseUsingRevision( );
00193 
00194   /// The ProxyDict fault handler
00195   /**
00196     * This method overload the default implementations of the same method
00197     * from the base class.
00198     *
00199     * @see CdbBdbProxyBase::faultHandler()
00200     */
00201     virtual T* faultHandler( IfdProxyDict* theDict,
00202                              const IfdKey& theKey,
00203                              AbsArg&       theArg );
00204 
00205 private:
00206 
00207   // The configuration parameters of the proxy
00208 
00209     std::string  _revisionName;
00210     unsigned int _partitionId;
00211 };
00212 
00213 
00214 #ifdef     BABAR_COMP_INST
00215 #include "CdbBdb/CdbBdbProxyBase.cc"
00216 #endif  // BABAR_COMP_INST
00217 
00218 #endif  // CDBBDB_PROXY_BASE_HH

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