00001 #ifndef CDBBDBTABLE_NTUPLE_SIMPLE_IMPL_P_HH 00002 #define CDBBDBTABLE_NTUPLE_SIMPLE_IMPL_P_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbNTupleSimpleImplP.ddl,v 1.2 2004/03/26 02:45:41 gapon Exp $ 00006 00007 #include "CdbBdbShared/CdbBdbSPagedVarrayP.hh" 00008 00009 #include "CdbBdbTable/CdbBdbNTupleP.hh" 00010 00011 /// An implementation of a base class for persistent n-tuples 00012 /** 00013 * This implementation uses a "paged v-array" for efficient storing of 00014 * n-tuple elements. The rows are unwrapped into a sigle dimension array 00015 * in the following order: 00016 * 00017 * - a row with 0 number gets stored first 00018 * - an element from a column with the number 0 gets stored first 00019 * 00020 * DESIGN NOTES: 00021 * 00022 * This class has been designed for the performance of the insertion operations 00023 * versus persistent space utilization efficiency. 00024 * That's why the capacity of a "paged" v-array used to store the elements 00025 * may be greater than the actual number of elements stored at a given instance 00026 * of time. 00027 * 00028 * The current resizing policy for the storage is "x2" meaning that every time 00029 * a new row is to be inserted and if there is no free space in the storage 00030 * the storage size gets increased by a factor of 2. 00031 * 00032 * Since this policy would result with the %25 average in-efficiency in the use 00033 * of the storage then there is a special "repack" method meant to truncate 00034 * the storage to match the actual number of rows stored in the array. 00035 * Normally the "repack" operation should be called when the construction of 00036 * the tuple is finished. 00037 * 00038 * @see CdbBdbNTupleBaseP 00039 * @see CdbBdbNTupleP 00040 */ 00041 template< class E > 00042 class CdbBdbNTupleSimpleImplP : public CdbBdbNTupleP<E> { 00043 00044 private: 00045 00046 /// Default constructor (IS NOT IMPLEMENTED) 00047 00048 CdbBdbNTupleSimpleImplP( ); 00049 00050 /// Copy constructor (IS NOT IMPLEMENTED) 00051 00052 CdbBdbNTupleSimpleImplP( const CdbBdbNTupleSimpleImplP<E>& ); 00053 00054 /// Assignment operator (IS NOT IMPLEMENTED) 00055 00056 CdbBdbNTupleSimpleImplP<E>& operator=( const CdbBdbNTupleSimpleImplP<E>& ); 00057 00058 public: 00059 00060 /// Constructor 00061 /** 00062 * @see CdbBdbNTupleBaseP::CdbBdbNTupleBaseP 00063 * @see CdbBdbNTupleP::CdbBdbNTupleP 00064 */ 00065 CdbBdbNTupleSimpleImplP( d_ULong theNumberOfColumns, 00066 const std::string& theName, 00067 const std::string& theDescription, 00068 const std::vector<std::string>& theColumnNames ); 00069 00070 /// Destructor 00071 00072 virtual ~CdbBdbNTupleSimpleImplP ( ); 00073 00074 /// Get the number of rows in the tuple 00075 /** 00076 * Implements a virtual method defined in the base class. 00077 * 00078 * @see CdbBdbNTupleP::rows 00079 */ 00080 virtual d_ULong rows( ) const; 00081 00082 /// Get a row at a specified position 00083 /** 00084 * Implements a virtual method defined in the base class. 00085 * 00086 * @see CdbBdbNTupleP::get_row 00087 */ 00088 virtual CdbStatus get_row( std::vector<E>& theRow, 00089 const d_ULong theNumber ) const; 00090 00091 /// Append a row by the end of an existing list 00092 /** 00093 * Implements a virtual method defined in the base class. 00094 * 00095 * @see CdbBdbNTupleP::append_row 00096 */ 00097 virtual CdbStatus append_row( const std::vector<E>& theRow ); 00098 00099 /// Repack the internal storage of the tuple 00100 /** 00101 * Implements a virtual method defined in the base class. 00102 * 00103 * @see CdbBdbNTupleP::repack 00104 */ 00105 virtual CdbStatus repack( ); 00106 00107 private: 00108 00109 // The actual number of columns. This number may be less than the capacity 00110 // of the data storage. See 'DESIGN NOTES' at the definition of the current 00111 // class for details. 00112 00113 d_ULong _rows; 00114 00115 // The storage for the tuple elements 00116 00117 ooRef( CdbBdbSPagedVarrayP<E> ) _dataRef; 00118 }; 00119 00120 // Explicit template instantiation for n-tuples of certain types of elements. 00121 // 00122 // In particular this macro is used to make explicit template instantiations 00123 // for so called predefined "primitive types" known to Objy API. N-tuples for 00124 // others (user defined typs of elmenets) should be instantiated using a bit 00125 // more extended form of a macro defined later. 00126 // 00127 // The macro definition assumes that the corresponding template instances have 00128 // already been made for Paged V-Array. 00129 // 00130 // NOTE: This macro can't be used to instantiate n-tuple of "ooBoolean" type 00131 // because this type may conflicts with "ooInt8" on some platforms. 00132 00133 #define EXPLICIT_INSTANTIATE_CdbBdbNTupleSimpleImplP_NOPVARRAY_1( E ) \ 00134 template class CdbBdbNTupleP< E >; \ 00135 template class CdbBdbNTupleSimpleImplP< E > 00136 00137 #define EXPLICIT_INSTANTIATE_CdbBdbNTupleSimpleImplP_NOPVARRAY_2( E1, E2 ) \ 00138 template class CdbBdbNTupleP< E1, E2 >; \ 00139 template class CdbBdbNTupleSimpleImplP< E1, E2 > 00140 00141 /// Macros for the explicit template instantiation of non-trivial types of elements. 00142 /** 00143 * The macro will provide all the necessary declarations for arbitrary 00144 * type of elements. This instantiation is required by Objectivity/DDL compilation 00145 * system to put the new classes into the federation's schema. 00146 * 00147 * Note that unlike the primitive types case, this instantiation will also 00148 * make template instantiation for the Paged V-Array. 00149 * 00150 * GENERAL NOTE: Be carefull when doing explicit template instantiations 00151 * in Objectivity/DDL API to avoid potential library conflicts 00152 * when the same template is defined in two or more packages 00153 * (libraries)!!! 00154 * 00155 * As a solution put a common instance of a template into one package 00156 * and use it from there. 00157 */ 00158 #define EXPLICIT_INSTANTIATE_CdbBdbNTupleSimpleImplP_1( E ) \ 00159 EXPLICIT_INSTANTIATE_CdbBdbSPagedVarrayP_1( E ); \ 00160 template class CdbBdbNTupleP< E >; \ 00161 template class CdbBdbNTupleSimpleImplP< E > 00162 00163 #define EXPLICIT_INSTANTIATE_CdbBdbNTupleSimpleImplP_2( E1 , E2 ) \ 00164 EXPLICIT_INSTANTIATE_CdbBdbSPagedVarrayP_2( E1 , E2 ); \ 00165 template class CdbBdbNTupleP< E1 , E2 >; \ 00166 template class CdbBdbNTupleSimpleImplP< E1 , E2 > 00167 00168 // Template class implementation 00169 00170 #ifdef BABAR_COMP_INST 00171 #include "CdbBdbTable/CdbBdbNTupleSimpleImplP.cc" 00172 #endif /* BABAR_COMP_INST */ 00173 00174 #endif /* CDBBDBTABLE_NTUPLE_SIMPLE_IMPL_P_HH */
1.3-rc3