00001 #ifndef CDB_PROXY_BASE_HH
00002 #define CDB_PROXY_BASE_HH
00003
00004
00005
00006
00007 #include "CdbBase/CdbProxyCache.hh"
00008 #include "ProxyDict/IfdDataProxyTemplate.hh"
00009
00010 class CdbDefStrategy;
00011
00012 #include <memory>
00013 #include <vector>
00014
00015
00016
00017
00018
00019
00020
00021
00022 template< class T >
00023 class CdbProxyBase : public IfdDataProxyTemplate<T>,
00024 public CdbProxyCache {
00025
00026 private:
00027
00028
00029
00030
00031
00032 CdbProxyBase( const CdbProxyBase<T>& );
00033
00034
00035
00036
00037
00038 CdbProxyBase<T>& operator=( const CdbProxyBase<T>& );
00039
00040 public:
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 explicit CdbProxyBase( CdbDefStrategy* theStrategy = 0 );
00051
00052
00053
00054 virtual ~CdbProxyBase( );
00055
00056
00057
00058
00059
00060
00061 virtual T* faultHandler( IfdProxyDict* theDict,
00062 const IfdKey& theKey,
00063 AbsArg& theArg );
00064
00065
00066
00067
00068
00069
00070 virtual void storeHandler( IfdProxyDict* theDict,
00071 const IfdKey& theKey,
00072 AbsArg& theArg,
00073 T* theObject );
00074
00075
00076
00077
00078
00079
00080 virtual void testCache( );
00081
00082 protected:
00083
00084
00085
00086
00087
00088
00089
00090
00091 virtual T* redefinedFaultHandler( const std::vector<CdbProxyElement>& theListOfElements ) = 0;
00092
00093
00094
00095
00096
00097
00098
00099
00100 virtual bool tryAnotherTime( const BdbTime& theOriginalTime,
00101 const std::vector<CdbProxyElement>& theListOfElements,
00102 BdbTime& TheOtherTime ) ;
00103
00104
00105
00106 T* transientCache( ) { return _transient.get( ); }
00107
00108
00109
00110 void setTransientCache( T* theNewTransientPtr ) { _transient.reset( theNewTransientPtr ); }
00111
00112
00113
00114 BdbTime faultTime( ) const;
00115
00116
00117
00118 void invalidateTransientCache( ) { setTransientCache( 0 ); }
00119
00120
00121
00122 const CdbDefStrategy* strategy( ) const { return _strategy.get( ); }
00123
00124
00125
00126 void setStrategy( CdbDefStrategy* theNewStrategyPtr ) { _strategy.reset( theNewStrategyPtr ); }
00127
00128 private:
00129
00130
00131
00132 std::auto_ptr<CdbDefStrategy> _strategy;
00133
00134
00135
00136 std::auto_ptr<T> _transient;
00137 friend class CdbRTestUtility;
00138
00139 };
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 template< class T >
00151 class CdbProxyBaseUsingRevision : public CdbProxyBase<T> {
00152
00153 private:
00154
00155
00156
00157
00158
00159 CdbProxyBaseUsingRevision( );
00160
00161
00162
00163
00164
00165 CdbProxyBaseUsingRevision( const CdbProxyBaseUsingRevision<T>& );
00166
00167
00168
00169
00170
00171 CdbProxyBaseUsingRevision<T>& operator=( const CdbProxyBaseUsingRevision<T>& );
00172
00173 public:
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 explicit CdbProxyBaseUsingRevision( const std::string& theRevisionName,
00188 unsigned int thePartitionId = 0,
00189 CdbDefStrategy* theStrategy = 0 );
00190
00191
00192
00193 virtual ~CdbProxyBaseUsingRevision( );
00194
00195
00196
00197
00198
00199
00200
00201
00202 virtual T* faultHandler( IfdProxyDict* theDict,
00203 const IfdKey& theKey,
00204 AbsArg& theArg );
00205
00206 private:
00207
00208
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