00001 #ifndef CDBBDB_PROXY_BASE_HH
00002 #define CDBBDB_PROXY_BASE_HH
00003
00004
00005
00006
00007 #include "CdbBdb/CdbBdbProxyCache.hh"
00008 #include "ProxyDict/IfdDataProxyTemplate.hh"
00009
00010 class BdbCondDefStrategy;
00011
00012 #include <memory>
00013 #include <vector>
00014
00015
00016
00017
00018
00019
00020
00021
00022 template< class T >
00023 class CdbBdbProxyBase : public IfdDataProxyTemplate<T>,
00024 public CdbBdbProxyCache {
00025
00026 private:
00027
00028
00029
00030
00031
00032 CdbBdbProxyBase( const CdbBdbProxyBase<T>& );
00033
00034
00035
00036
00037
00038 CdbBdbProxyBase<T>& operator=( const CdbBdbProxyBase<T>& );
00039
00040 public:
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 explicit CdbBdbProxyBase( BdbCondDefStrategy* theStrategy = 0 );
00051
00052
00053
00054 virtual ~CdbBdbProxyBase( );
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<CdbBdbProxyElement>& theListOfElements ) = 0;
00092
00093
00094
00095
00096
00097
00098
00099
00100 virtual bool tryAnotherTime( const BdbTime& theOriginalTime,
00101 const std::vector<CdbBdbProxyElement>& 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 BdbCondDefStrategy* strategy( ) const { return _strategy.get( ); }
00123
00124
00125
00126 void setStrategy( BdbCondDefStrategy* theNewStrategyPtr ) { _strategy.reset( theNewStrategyPtr ); }
00127
00128 private:
00129
00130
00131
00132 std::auto_ptr<BdbCondDefStrategy> _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 template< class T >
00150 class CdbBdbProxyBaseUsingRevision : public CdbBdbProxyBase<T> {
00151
00152 private:
00153
00154
00155
00156
00157
00158 CdbBdbProxyBaseUsingRevision( );
00159
00160
00161
00162
00163
00164 CdbBdbProxyBaseUsingRevision( const CdbBdbProxyBaseUsingRevision<T>& );
00165
00166
00167
00168
00169
00170 CdbBdbProxyBaseUsingRevision<T>& operator=( const CdbBdbProxyBaseUsingRevision<T>& );
00171
00172 public:
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 explicit CdbBdbProxyBaseUsingRevision( const std::string& theRevisionName,
00187 unsigned int thePartitionId = 0,
00188 BdbCondDefStrategy* theStrategy = 0 );
00189
00190
00191
00192 virtual ~CdbBdbProxyBaseUsingRevision( );
00193
00194
00195
00196
00197
00198
00199
00200
00201 virtual T* faultHandler( IfdProxyDict* theDict,
00202 const IfdKey& theKey,
00203 AbsArg& theArg );
00204
00205 private:
00206
00207
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