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

CdbProxyBase.hh

Go to the documentation of this file.
00001 #ifndef CDB_PROXY_BASE_HH
00002 #define CDB_PROXY_BASE_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbProxyBase.hh,v 1.2 2005/07/13 20:00:58 jtinslay Exp $
00006 
00007 #include "CdbBase/CdbProxyCache.hh"
00008 #include "ProxyDict/IfdDataProxyTemplate.hh"
00009 
00010 class CdbDefStrategy;
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 CdbProxyBase : public IfdDataProxyTemplate<T>,
00024                      public CdbProxyCache {
00025 
00026 private:
00027 
00028   /// The copy constructor (NOT IMPLEMENTED)
00029   /**
00030     * More details...
00031     */
00032     CdbProxyBase( const CdbProxyBase<T>& );
00033 
00034   /// The asignment operator (NOT IMPLEMENTED)
00035   /**
00036     * More details...
00037     */
00038     CdbProxyBase<T>& operator=( const CdbProxyBase<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 CdbProxyBase( CdbDefStrategy* theStrategy = 0 );
00051 
00052   /// The destructor
00053 
00054     virtual ~CdbProxyBase( );
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<CdbProxyElement>& 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<CdbProxyElement>& 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 CdbDefStrategy* strategy( ) const { return _strategy.get( ); }
00123 
00124   /// Modify the strategy object
00125 
00126     void setStrategy( CdbDefStrategy* theNewStrategyPtr ) { _strategy.reset( theNewStrategyPtr ); }
00127 
00128 private:
00129 
00130   // The strategy
00131 
00132     std::auto_ptr<CdbDefStrategy> _strategy;
00133 
00134   // The transient cache
00135 
00136     std::auto_ptr<T> _transient;
00137     friend class CdbRTestUtility;
00138 
00139 };
00140 
00141 /// This class specializes a base class for the Condition/DB proxies
00142 /**
00143   * This specialized version of the proxy base class can be used when
00144   * condition objects are fetched from the CDB using an explicitly specified
00145   * revision name and partition identifier rather than relying on configurations
00146   * of condityions in teh current view.
00147   *
00148   * @see CdbProxyBase
00149   */
00150 template< class T >
00151 class CdbProxyBaseUsingRevision : public CdbProxyBase<T> {
00152 
00153 private:
00154 
00155   /// The default constructor (NOT IMPLEMENTED)
00156   /**
00157     * More details...
00158     */
00159     CdbProxyBaseUsingRevision( );
00160 
00161   /// The copy constructor (NOT IMPLEMENTED)
00162   /**
00163     * More details...
00164     */
00165     CdbProxyBaseUsingRevision( const CdbProxyBaseUsingRevision<T>& );
00166 
00167   /// The asignment operator (NOT IMPLEMENTED)
00168   /**
00169     * More details...
00170     */
00171     CdbProxyBaseUsingRevision<T>& operator=( const CdbProxyBaseUsingRevision<T>& );
00172 
00173 public:
00174 
00175   /// The normal constructor
00176   /**
00177     * A revision to be used by the proxy when finding persistent objects is specified
00178     * by its name in a scope of a partition. Note, that for the regular conditions
00179     * the partition identifier is always 0.
00180     *
00181     * The last optional argument of the constructor takes the strategy object
00182     * for locating GenEnv parameters. If 0 pointer is passed then a default
00183     * strategy will be enforced.
00184     *
00185     * Note, that the ownreship of the strategy object is also passed to the constructor.
00186     */
00187     explicit CdbProxyBaseUsingRevision( const std::string& theRevisionName,
00188                                         unsigned int       thePartitionId = 0,
00189                                         CdbDefStrategy*    theStrategy    = 0 );
00190 
00191   /// The destructor
00192 
00193     virtual ~CdbProxyBaseUsingRevision( );
00194 
00195   /// The ProxyDict fault handler
00196   /**
00197     * This method overload the default implementations of the same method
00198     * from the base class.
00199     *
00200     * @see CdbProxyBase::faultHandler()
00201     */
00202     virtual T* faultHandler( IfdProxyDict* theDict,
00203                              const IfdKey& theKey,
00204                              AbsArg&       theArg );
00205 
00206 private:
00207 
00208   // The configuration parameters of the proxy
00209 
00210     std::string  _revisionName;
00211     unsigned int _partitionId;
00212 };
00213 
00214 
00215 #ifdef     BABAR_COMP_INST
00216 #include "CdbBase/CdbProxyBase.cc"
00217 #endif  // BABAR_COMP_INST
00218 
00219 #endif  // CDB_PROXY_BASE_HH

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