Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

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

/CdbBase/CdbIItr.hh

Go to the documentation of this file.
00001 #ifndef CDB_I_ITR_HH
00002 #define CDB_I_ITR_HH
00003 
00004 #include "CdbBase/CdbCommon.hh"
00005 
00006 /// The base interface for the iterator classes
00007 /**
00008   * This is a template base class for the other iterators used in the project.
00009   * The class is parametrized by the object type to be iterated.
00010   */
00011 template< typename T >
00012 class CdbIItr {
00013 
00014 public:
00015 
00016   /// This is a type of a base iterator interface
00017   ///
00018     typedef CdbIItr<T> InterfaceType;
00019 
00020   /// Introduce a type definition for the purpose of easier reference
00021   /**
00022     * This definition provides access to the type of the parameter used
00023     * for the concrete template instantiation.
00024     */
00025     typedef T ValueType;
00026 
00027 public:
00028 
00029   /// Make a clone of itself
00030   /**
00031     * This method has to be implemented by subclasses. It's meant to provide
00032     * a clone of the iterator and return a pointer onto a new object.
00033     *
00034     * @return a pointer onto a clone
00035     */
00036     virtual CdbIItr<T>* clone( ) const = 0;
00037 
00038   /// The destructor
00039   /**
00040     * Making the destructor of this clas virtual reinforces the derived classes
00041     * also have the virtual ones.
00042     */
00043     virtual ~CdbIItr( );
00044 
00045   /// Reset an iterator to its initial state.
00046   /**
00047     * This will reset an iterator to the state it was before the very first
00048     * call to the CdbIItr::next method.
00049     *
00050     * @see CdbIItr::next
00051     *
00052     * @return the completion status
00053     */
00054     virtual CdbStatus reset( ) = 0;
00055 
00056   /// Advance an iterator to the next position.
00057   /**
00058     * This is the first method to be called upon the initialization of the
00059     * of the iterator's scope.
00060     *
00061     * @return true if the operation succeded
00062     */
00063     virtual bool next( ) = 0;
00064 
00065   /// Obtain the currently reffered value.
00066   /**
00067     * This operation makes only sense if the previously issued CdbIItr::next
00068     * operation succeded. Otherwise an undefined value will be returned.
00069     *
00070     * @see CdbIItr::next
00071     *
00072     * @return a value of the currently reffered value
00073     */
00074     virtual ValueType value( ) = 0;
00075 
00076   /// Check if an iterator is valid.
00077   /**
00078     * "Valid" means that an iterator is in the right scope, is pointing onto
00079     * some valid element and is not past the end of the iterated sequence.
00080     *
00081     * @return true if valid
00082     */
00083     virtual bool isValid( ) = 0;
00084 };
00085 
00086 #ifdef     BABAR_COMP_INST
00087 #include "CdbBase/CdbIItr.cc"
00088 #endif  // BABAR_COMP_INST
00089 
00090 #endif  // CDB_I_ITR_HH

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002