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

CdbBdbSRevCollectionP.ddl

Go to the documentation of this file.
00001 #ifndef CDBBDBSHARED_REV_COLLECTION_P_HH
00002 #define CDBBDBSHARED_REV_COLLECTION_P_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbSRevCollectionP.ddl,v 1.10 2004/08/06 05:54:25 bartoldu Exp $
00006 
00007 #include "BdbUtil/Bdb.hh"
00008 #include "ooMap.h"
00009 
00010 #include "CdbBase/CdbItr.hh"
00011 
00012 #include "CdbBdbShared/CdbBdbSRevisionP.hh"
00013 #include "CdbBdbShared/CdbBdbSTimeLineP.hh"
00014 
00015 #include "BdbTime/BdbTime.hh"
00016 
00017 #include <iostream>
00018 
00019 //--------------------------------------------------------------------------------------
00020 // Explicit template instantiatin for the persistent TimeLine used by this class only --
00021 //--------------------------------------------------------------------------------------
00022 
00023 EXPLICIT_INSTANTIATE_CdbBdbSTimeLineP_1( BdbRef(CdbBdbSRevisionP) );
00024 
00025 /// A collection of revisions
00026 /**
00027   * This is a persistent implementation for the timeline (in the insertion
00028   * dimension) of "revisions". Each revision occupies a "validity" interavl in
00029   * the "insertion" timeline. When a new revision is put into the collection
00030   * it's inserted into an apporpriate position.
00031   */
00032 class CdbBdbSRevCollectionP : public BdbPersObj {
00033 
00034 private:
00035 
00036     typedef CdbBdbSTimeLineInterval< BdbRef(CdbBdbSRevisionP) > Interval;
00037 
00038 public:
00039 
00040   // Default constructor
00041 
00042     CdbBdbSRevCollectionP( );
00043 
00044   // Destructor
00045 
00046     virtual ~CdbBdbSRevCollectionP( );
00047 
00048   /// Insert a revision into the collection
00049   /**
00050     * The specified revision is registered in the collection by its name
00051     * (must be present) and its identifier (revision creation time). The values
00052     * of the correspondinig keys are obtained through the revision class
00053     * interface.
00054     *
00055     * This operation does not have any side effects for the inserted revisions.
00056     *
00057     * The operation may fail if any of the following conditions is met:
00058     *
00059     *     - the passed revision exposes inproper identification (missing
00060     *       name or wrong identifier)
00061     *     - any system (Objectivity) error occures
00062     *     - the collection is internally inconsistent
00063     *     - specified revision is "out-of-sequence" (see documentation
00064     *       for the explanation of the concepts of revisions).
00065     */
00066     CdbStatus insert( const BdbRef(CdbBdbSRevisionP)& theRevisionRef );
00067 
00068   /// Find a revision in the collection by the revision identifier
00069   /**
00070     * Remember, that "revision id" is a point in the "insertion" time
00071     * dimension when a revison was created.
00072     *
00073     * The method uses "exact match" method to find the revision.
00074     *
00075     * In addition to usual (Success or Error) completion status values,
00076     * this one can also return CdbStatus::NotFound if the revision was not found.
00077     */
00078     CdbStatus find( const BdbTime&            theId,            /**< the revision identifier */
00079                     BdbRef(CdbBdbSRevisionP)& theRevisionRef    /**< the revision reference to be set up upon completion */
00080                   ) const;
00081 
00082   /// Find a revision in the collection by its name
00083   /**
00084     * The name passed as a parameter should not be 0 pointer.
00085     *
00086     * In addition to usual (Success or Error) completion status values,
00087     * this one can also return CdbStatus::NotFound if the revision was not found.
00088     */
00089     CdbStatus find( const char*               theName,         /**< the revision name */
00090                     BdbRef(CdbBdbSRevisionP)& theRevisionRef   /**< the revision reference to be set up upon completion */
00091                   ) const;
00092 
00093   /// Get the identifier for the most recent revision if any
00094   /**
00095     * Return CdbStatus::NotFound if there is no revisions in
00096     * the collection.
00097     */
00098     CdbStatus last( BdbTime& theId                              /**< the value of the identifier to be returned */
00099                   ) const;
00100 
00101   /// Set an iterator for revisions identifiers
00102 
00103     CdbItr<BdbTime> iterator_identifiers( ) const;
00104 
00105   /// Set an iterator for revisions names
00106 
00107     CdbItr<const char*> iterator_names( ) const;
00108 
00109   /// Dump the contents of the collection
00110   /**
00111     */
00112     void dump( std::ostream& o ) const;
00113 
00114 private:
00115 
00116   /// Insert specified revision into the map
00117   /**
00118     * The revision name will be inquired from the passed revision
00119     * as a key for the registration.
00120     */
00121     CdbStatus insertIntoMap( const BdbRef(CdbBdbSRevisionP)& theRevisionRef );
00122 
00123   /// Remove a revision into a map
00124   /**
00125     * The method does not check the value of passed name. Non-zero string
00126     * is expected.
00127     */
00128     void removeFromMap( const char* theName );
00129 
00130   /// Insert specified revision into the TimeLine of "duration"intervals
00131   /**
00132     * The revision identifier will be inquired from the passed revision
00133     * as a key for the registration.
00134     */
00135     CdbStatus insertIntoTimeLine( const BdbRef(CdbBdbSRevisionP)& theRevisionRef );
00136 
00137 private:
00138 
00139   /// The TimeLine of the "revision duration intervals"
00140   /**
00141     * This includes both the index for these intervals as well as
00142     * a double linked list of them.
00143     */
00144     BdbRef( CdbBdbSTimeLineP< BdbRef(CdbBdbSRevisionP) > ) _timeLineRef;
00145 
00146   /// The (oo-)map of revisions.
00147   /**
00148     * This map provides sorting facility for the revisions according to their
00149     * given names.
00150     */
00151     BdbRef( BdbMap ) _mapRef;
00152 };
00153 
00154 #endif /* CDBBDBSHARED_REV_COLLECTION_P_HH */

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