Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbItr.hh

Go to the documentation of this file.
00001 #ifndef CDB_ITR_HH
00002 #define CDB_ITR_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbItr.hh,v 1.6 2005/07/26 00:06:25 gapon Exp $
00006 
00007 #include "CdbBase/CdbCommon.hh"
00008 #include "CdbBase/CdbIItr.hh"
00009 
00010 /// The generic implementation for the public iterators.
00011 /**
00012   * The class takes the only template parameter: T - a type of the values
00013   * operated by the iterator.
00014   *
00015   * @see CdbIItr
00016   */
00017 template < typename T >
00018 class CdbItr : public CdbIItr<T> {
00019 
00020 private:
00021 
00022   /// The assignment operator (NOT IMPLEMENTED)
00023   /**
00024     * This way of initializing the iterator is explicitly prohibited to avoid
00025     * ambiguity with the regulat assignment operation. That's because C++ doesn't
00026     * have the "explicit" keyword for assignment operators.
00027     *
00028     * Another potential problem of having this form of an assignment operator
00029     * would be related to potential shared ownership conflicts. If, for example,
00030     * there is a concrete derived class, and we're assigning one variable of that
00031     * class a value of the same class then the assignee would never know if
00032     * the "rhs" value should be taken over or if it's a temporary one. In the second
00033     * case we'll have the double deletion memory problem.
00034     *
00035     * So, let's just stay away of this form of an operator, the explicit class's
00036     * constructor does all job for us.
00037     */
00038     CdbItr& operator=( const CdbIItr<T>* thePtr );
00039 
00040 public:
00041 
00042   /// The default constructor.
00043   /**
00044     * Leaves the iterator in the invalid state.
00045     *
00046     * @see CdbIItr::isValid()
00047     */
00048     CdbItr( );
00049 
00050   /// The copy constructor
00051   /**
00052     * More details to come...
00053     */
00054     CdbItr( const CdbItr<T>& theItr );
00055 
00056   /// The constructor.
00057   /**
00058     * Initialize the iterator by a pointer onto a base class's object.
00059     *
00060     * NOTE: That we're taking over the ownership of the passed object.
00061     */
00062     explicit CdbItr( CdbIItr<T>* thePtr );
00063 
00064   /// The assignment operator
00065   /**
00066     * More details to come...
00067     */
00068     CdbItr& operator=( const CdbItr<T>& theItr );
00069 
00070   /// The destructor
00071   /**
00072     * Details...
00073     */
00074     virtual ~CdbItr( );
00075 
00076   /// Reset an iterator to its initial state.
00077   /**
00078     * This implements the corresponding method of the base class.
00079     *
00080     * @see CdbIItr::reset
00081     * @see CdbStatus
00082     */
00083     virtual CdbStatus reset( );
00084 
00085   /// Advance an iterator to the next position.
00086   /**
00087     * This implements the corresponding method of the base class.
00088     *
00089     * @see CdbIItr::next
00090     */
00091     virtual bool next( );
00092 
00093   /// Obtain the currently reffered value.
00094   /**
00095     * This implements the corresponding method of the base class.
00096     *
00097     * @see CdbIItr::value
00098     *
00099     * @return the current value the iterator is set on
00100     */
00101     virtual T value( );
00102 
00103   /// Check if an iterator is valid.
00104   /**
00105     * This implements the corresponding method of the base class.
00106     *
00107     * @see CdbIItr::isValid
00108     */
00109     virtual bool isValid( );
00110 
00111   /// Make a clone of itself
00112   /**
00113     * @see CdbIItr::clone()
00114     */
00115     virtual CdbIItr<T>* clone( ) const;
00116 
00117 private:
00118 
00119   /// Set up the internal context
00120   /**
00121     * Delete the previously held context and make a new one by cloning
00122     * the passed object.
00123     */
00124     void set( const CdbIItr<T>* thePtr );
00125 
00126 private:
00127 
00128   /// This is a pointer onto an object providing the real iterator.
00129 
00130     CdbIItr<T>* _myItr;
00131 };
00132 
00133 #ifdef     BABAR_COMP_INST
00134 #include "CdbBase/CdbItr.cc"
00135 #endif  // BABAR_COMP_INST
00136 
00137 #endif  // CDB_ITR_HH

Generated on Mon Dec 5 18:22:05 2005 for CDB by doxygen1.3-rc3