00001 #ifndef CDBBDBSHARED_ABS_BTREE_ITR_HH 00002 #define CDBBDBSHARED_ABS_BTREE_ITR_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbSAbsBtreeItr.hh,v 1.4 2002/09/23 22:41:06 gapon Exp $ 00006 00007 #include "CdbBase/CdbIItr.hh" 00008 00009 //--------------------------------------------- 00010 // Forward declaration for the target B-tree -- 00011 //--------------------------------------------- 00012 00013 template< class K, 00014 class FCP, 00015 class ORDER > 00016 class CdbBdbSAbsBtree; 00017 00018 /// The internal implementation for the public iterator for B-tree keys 00019 /** 00020 * This class provides the actual implementation of the B-tree browsing. 00021 * This class has the same template parameters as the B-tree class. 00022 * 00023 * DESIGN & IMPLEMENTATION NOTE: 00024 * 00025 * Due to current design of the abstract B-tree class the current 00026 * iterator's interface is type-intrusive. This may be solved later. 00027 * 00028 * @see CdbIItr 00029 * @see CdbBdbSAbsBtree 00030 */ 00031 template< class K, 00032 class FCP, 00033 class ORDER > 00034 class CdbBdbSAbsBtreeItr : public CdbIItr<K> { 00035 00036 public: 00037 00038 typedef typename CdbIItr<K>::ValueType ValueType; 00039 typedef typename CdbIItr<K>::InterfaceType InterfaceType; 00040 00041 private: 00042 00043 /// The default constructor (NOT IMPLEMENTED) 00044 /** 00045 * Is disabled... 00046 */ 00047 CdbBdbSAbsBtreeItr( ); 00048 00049 /// The assignment operator (NOT IMPLEMENTED) 00050 /** 00051 * Is disabled... 00052 */ 00053 CdbBdbSAbsBtreeItr& operator=( const CdbBdbSAbsBtreeItr<K,FCP,ORDER>& theItr ); 00054 00055 protected: 00056 00057 /// The copy constructor 00058 /** 00059 * The only reason why we have it implemented is because it's needed 00060 * to implement the clone method. 00061 * 00062 * @see CdbBdbSAbsBtreeItr::clone() 00063 */ 00064 CdbBdbSAbsBtreeItr( const CdbBdbSAbsBtreeItr<K,FCP,ORDER>& theItr ); 00065 00066 public: 00067 00068 /// The normal constructor 00069 /** 00070 * Non 0 pointer is expected. 00071 */ 00072 CdbBdbSAbsBtreeItr( const CdbBdbSAbsBtree<K,FCP,ORDER>* theTree ); 00073 00074 /// The destructor 00075 /** 00076 * Details... 00077 */ 00078 virtual ~CdbBdbSAbsBtreeItr( ); 00079 00080 /// Reset an iterator to its initial state. 00081 /** 00082 * This implements the corresponding method of the base class. 00083 * 00084 * @see CdbIItr::reset 00085 * @see CdbStatus 00086 */ 00087 virtual CdbStatus reset( ); 00088 00089 /// Advance an iterator to the next position. 00090 /** 00091 * This implements the corresponding method of the base class. 00092 * 00093 * @see CdbIItr::next() 00094 */ 00095 virtual bool next( ); 00096 00097 /// Obtain the currently reffered value. 00098 /** 00099 * This implements the corresponding method of the base class. 00100 * 00101 * @see CdbIItr::value() 00102 * @see CdbIItr::ValueType 00103 * 00104 * @return the current value the iterator is set on 00105 */ 00106 virtual ValueType value( ); 00107 00108 /// Check if an iterator is valid. 00109 /** 00110 * This implements the corresponding method of the base class. 00111 * 00112 * @see CdbIItr::isValid() 00113 */ 00114 virtual bool isValid( ); 00115 00116 /// Make a clone of itself 00117 /** 00118 * @see CdbIItr::clone() 00119 */ 00120 virtual InterfaceType* clone( ) const; 00121 00122 private: 00123 00124 /// Keep searching the next element at the parent of current node 00125 /** 00126 * This is a recursive procedure, which will only return "true" if 00127 * an appropriate key is found and the iterator's context is set to point 00128 * onto that element. 00129 */ 00130 bool backToParent( ); 00131 00132 private: 00133 00134 const CdbBdbSAbsBtree<K,FCP,ORDER>* _myTreePtr; 00135 00136 bool _isValid; 00137 bool _hasEverBeenAdvanced; 00138 00139 d_ULong _node; 00140 CdbBdbSBtreeNode<K,ORDER> _nodeValue; 00141 int _currentElement; 00142 }; 00143 00144 #ifdef BABAR_COMP_INST 00145 #include "CdbBdbShared/CdbBdbSAbsBtreeItr.cc" 00146 #endif /* BABAR_COMP_INST */ 00147 00148 #endif // CDBBDBSHARED_ABS_BTREE_ITR_HH
1.3-rc3