00001 #ifndef CDBROOREADONLY_VECTOR_COLLECTION_R_RDL
00002 #define CDBROOREADONLY_VECTOR_COLLECTION_R_RDL
00003
00004
00005
00006
00007 #include "CdbBase/CdbCPtr.hh"
00008
00009 #include "CdbRooReadonly/CdbRooRoPersistentCollectionR.hh"
00010
00011 #include <iostream>
00012 #include <vector>
00013 #include <string>
00014
00015 class TTree;
00016
00017
00018
00019
00020
00021
00022
00023 template< class T >
00024 struct CdbRooRoVectorCollection_PlainPointerPolicy {
00025
00026 typedef T* PointerType;
00027
00028 static void delete_object( PointerType ptr ) { delete ptr; }
00029
00030 static bool is_null( PointerType ptr ) { return (0 == ptr); }
00031
00032 static PointerType null_object( ) { return 0; }
00033
00034 static T* to_plain_pointer( PointerType ptr ) { return ptr; }
00035
00036 static PointerType copy_object( const CdbCPtr<T>& theObjectPtr ) { return new T( *theObjectPtr ); }
00037
00038 static PointerType copy_object( const T* theObjectPtr ) { return new T( *theObjectPtr ); }
00039 };
00040
00041
00042
00043 template< class T >
00044 struct CdbRooRoVectorCollection_SmartPointerPolicy {
00045
00046 typedef CdbCPtr<T> PointerType;
00047
00048 static void delete_object( PointerType ptr ) { }
00049
00050 static bool is_null( PointerType ptr ) { return ptr.isNull( ); }
00051
00052 static PointerType null_object( ) { return PointerType( ); }
00053
00054 static T* to_plain_pointer( PointerType ptr ) { return ptr.get( ); }
00055
00056 static PointerType copy_object( const CdbCPtr<T>& theObjectPtr ) { return theObjectPtr; }
00057
00058 static PointerType copy_object( const T* theObjectPtr ) { return new T( *theObjectPtr ); }
00059 };
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 template< class T,
00095 class STORAGE_POLICY = CdbRooRoVectorCollection_PlainPointerPolicy<T> >
00096
00097 class CdbRooRoVectorCollectionR : public CdbRooRoPersistentCollectionR {
00098
00099 public:
00100
00101
00102
00103
00104
00105 CdbRooRoVectorCollectionR( );
00106
00107
00108
00109
00110
00111
00112 CdbRooRoVectorCollectionR( unsigned int theInitialSize );
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 CdbRooRoVectorCollectionR( const CdbRooRoVectorCollectionR<T,STORAGE_POLICY>& theOther );
00136
00137
00138
00139 virtual ~CdbRooRoVectorCollectionR( );
00140
00141
00142
00143
00144
00145
00146
00147 CdbRooRoVectorCollectionR<T,STORAGE_POLICY>& operator=( const CdbRooRoVectorCollectionR<T,STORAGE_POLICY>& theOther );
00148
00149 UInt_t size( ) const { return _size; }
00150
00151
00152
00153
00154
00155
00156 virtual CdbStatus resize( UInt_t theNewSize );
00157
00158 virtual CdbStatus addElement( const T& theObject );
00159
00160 virtual CdbStatus addElement( const CdbCPtr<T>& theObjectPtr );
00161
00162 virtual CdbStatus elementAt( UInt_t theIndex,
00163 T& theObject ) const;
00164
00165 virtual CdbStatus elementAt( UInt_t theIndex,
00166 CdbCPtr<T>& theObjectPtr ) const;
00167
00168 virtual void dump( std::ostream& o,
00169 const std::string& indent = "" ) const;
00170
00171 protected:
00172
00173
00174
00175
00176
00177
00178
00179 virtual CdbStatus storeSubCollectionsAt( const CdbRooRoCollectionAddressR& theCollectionAddress,
00180 const CdbCPtr<TFile>& theFilePtr,
00181 Int_t& theNumBytesStored );
00182 private:
00183
00184
00185
00186 CdbStatus loadElementAt( UInt_t theIndex ) const;
00187
00188 private:
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207 mutable CdbCPtr<TFile> _tFilePtr;
00208 mutable CdbCPtr<TTree> _tTreePtr;
00209 mutable T* _tObjectPtr;
00210
00211 mutable std::vector< typename STORAGE_POLICY::PointerType > _tCachedObjects;
00212
00213
00214
00215 UInt_t _size;
00216
00217 ClassDefT(CdbRooRoVectorCollectionR<T>,1);
00218 };
00219
00220
00221
00222 #ifndef __CINT__
00223 #include "CdbRooReadonly/CdbRooRoVectorCollectionR.cc"
00224 #endif
00225 #endif