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

CdbRooRoMetaDataR.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbRooRoMetaDataR.cc,v 1.7 2005/11/11 01:41:27 gapon Exp $
00003 
00004 /// The implementation file for the CdbRooRoMetaDataR class
00005 /**
00006   * @see CdbRooRoMetaDataR
00007   */
00008 
00009 #include "BaBar/BaBar.hh"
00010 
00011 #include "CdbRooReadonly/CdbRooRoMetaDataR.hh"
00012 
00013 #include "CdbBase/CdbTimeUtils.hh"
00014 
00015 #include "ErrLogger/ErrLog.hh"
00016 
00017 #include <assert.h>
00018 #include <string.h>
00019 
00020 #include <iostream>
00021 using std::cout;
00022 using std::endl;
00023 
00024 namespace {
00025 
00026     /////////////////////////////////////
00027     // Class: CombinedIntervalIterator //
00028     /////////////////////////////////////
00029 
00030     class CombinedIntervalIterator : public CdbItr<CdbRooRoCi>::InterfaceType {
00031 
00032     private:
00033 
00034       /// The default constructor (NOT IMPLEMENTED)
00035 
00036         CombinedIntervalIterator( );
00037 
00038       /// The assignment operator (NOT IMPLEMENTED)
00039 
00040         CombinedIntervalIterator& operator=( const CombinedIntervalIterator& theItr );
00041 
00042     protected:
00043 
00044       /// The copy constructor
00045       /**
00046         * The only reason why we have it implemented is because it's needed
00047         * to implement the clone method.
00048         *
00049         * @see CombinedIntervalIterator::clone()
00050         */
00051         CombinedIntervalIterator( const CombinedIntervalIterator& theItr ) :
00052             _viCollection       (theItr._viCollection),
00053             _oiCollection       (theItr._oiCollection),
00054             _beginTime          (theItr._beginTime),
00055             _endTime            (theItr._endTime),
00056             _isValid            (theItr._isValid),
00057             _hasEverBeenAdvanced(theItr._hasEverBeenAdvanced),
00058             _value              (theItr._value),
00059             _viItr              (theItr._viItr)
00060         { }
00061 
00062     public:
00063 
00064       /// The normal constructor
00065 
00066         CombinedIntervalIterator( const CdbRooRoViCollectionR& theViCollection,
00067                                   const CdbRooRoOiCollectionR& theOiCollection,
00068                                   const BdbTime&               theBeginTime,
00069                                   const BdbTime&               theEndTime ) :
00070             _viCollection       (theViCollection),
00071             _oiCollection       (theOiCollection),
00072             _beginTime          (theBeginTime),
00073             _endTime            (theEndTime),
00074             _isValid            (false),
00075             _hasEverBeenAdvanced(false)
00076         { }
00077 
00078       /// The destructor
00079 
00080         virtual ~CombinedIntervalIterator( )
00081         { }
00082 
00083       /// Reset an iterator to its initial state.
00084       /**
00085         * This implements the corresponding method of the base class.
00086         *
00087         * @see CdbIItr::reset
00088         * @see CdbStatus
00089         */
00090         virtual CdbStatus reset( )
00091         {
00092             _isValid             = false;
00093             _hasEverBeenAdvanced = false;
00094 
00095             return CdbStatus::Success;
00096         }
00097 
00098       /// Try advancing the input iterator
00099 
00100         bool tryNext( )
00101         {
00102             bool result = false;
00103             do {
00104 
00105               // Advance the VI iterator to the next interval
00106 
00107                 if( !_viItr.next( )) break;
00108 
00109                 CdbRooRoViR vi = _viItr.value( );
00110 
00111               // Check for the end condition requering that the begin time
00112               // of found visible interval fall into the iterator's validity limits.
00113               //
00114               // Either of two scenarious:
00115               //
00116               // - begin time of the interval #1 falls into Interval #2
00117               // - begin time of the interval #2 falls into Interval #1
00118               //
00119               // In other "words":
00120               //
00121               //   #1    [.....)
00122               //   #2   [....)
00123               //
00124               // or:
00125               //
00126               //   #1  [.....)
00127               //   #2    [.....)
00128 /*
00129  * DEBUG
00130                 cout << "_beginTime = " << _beginTime.getGmtSec( ) << "." << _beginTime.getGmtNsec( ) << endl
00131                      << "vi.begin( )   = " << vi.begin( ).getGmtSec  ( ) << "." << vi.begin( ).getGmtNsec  ( ) << endl
00132                      << "vi.end( )     = " << vi.end( ).getGmtSec    ( ) << "." << vi.end( ).getGmtNsec    ( ) << endl
00133                      << "_endTime   = " << _endTime.getGmtSec  ( ) << "." << _endTime.getGmtNsec  ( ) << endl;
00134 */
00135                 if( ! ((( _beginTime  <= vi.begin( )) && ( vi.begin( ) < _endTime )) ||
00136                        (( vi.begin( ) <= _beginTime ) && ( _beginTime  < vi.end( ))))) break;
00137 
00138               // Construct the current value
00139               //
00140               // NOTE: We're not changing the "visibility" of found interval
00141               //       even if it partially falls beyond the limits of the current
00142               //       iterator. It's up to the application's logic to catch this
00143               //       problem. See the corresponding desciption in the client
00144               //       class's method.
00145 
00146                 if( 0 == vi.value( )){
00147 
00148                   // This is a "hole" in the visible timeline because there is
00149                   // no any object for the duration of foudn visible interval.
00150 
00151                     _value = CdbRooRoCi( vi.begin( ),
00152                                          vi.end( ));
00153                 } else {
00154 
00155                   // Ther emust be a valid object. Get the "original" interval
00156                   // describing it.
00157 
00158                     CdbRooRoOiR oi;
00159                     BdbTime   beginOfDuration;  // not used
00160                     BdbTime   endOfDuration;    // not used
00161 
00162                     if( CdbStatus::Success != _oiCollection.find( vi.value( ),
00163                                                                   oi,
00164                                                                   beginOfDuration,
00165                                                                   endOfDuration )) {
00166 
00167                         assert( 0 );    // FATAL ERROR: inconsistent "visible"
00168                                         //              and "original" collections.
00169                         break;
00170                     }
00171                     _value = CdbRooRoCi( vi.begin( ),
00172                                          vi.end( ),
00173                                          oi );
00174                 }
00175 
00176               // Done.
00177 
00178                 result = true;
00179 
00180             } while( false );
00181 
00182             return result;
00183         }
00184 
00185       /// Advance an iterator to the next position.
00186       /**
00187         * This implements the corresponding method of the base class.
00188         *
00189         * @see CdbIItr::next()
00190         */
00191         virtual bool next( )
00192         {
00193             if( !_isValid ) {
00194 
00195                 if( !_hasEverBeenAdvanced ) {
00196                     _hasEverBeenAdvanced = true;
00197 
00198                     _viItr = _viCollection.iterator( _beginTime );
00199 
00200                 } else {
00201 
00202                   // This iterator should remain at "PAST_LAST_ELEMENT" state. The only way
00203                   // to get out of this state is to to call ::reset() method.
00204 
00205                     return false;
00206                 }
00207             }
00208             if( !_isValid ) {
00209 
00210               // The first attemp to advance an iterator since it was initialized
00211 
00212                 _isValid = tryNext( );
00213 
00214             } else if( _isValid && _viItr.isValid( )) {
00215 
00216               // We keep iterating in the valid state of the input iterator
00217 
00218                 _isValid = tryNext( );
00219 
00220             } else {
00221 
00222               // Now we've got into the "PAST_LAST_ELEMENT" state.
00223 
00224                _isValid = false;
00225             }
00226             return _isValid;
00227         }
00228 
00229       /// Obtain the currently reffered value.
00230       /**
00231         * This implements the corresponding method of the base class.
00232         *
00233         * @see CdbIItr::value()
00234         * @see CdbIItr::ValueType
00235         *
00236         * @return the current value the iterator is set on
00237         */
00238         virtual ValueType value( )
00239         {
00240             if( ! _isValid ) assert( 0 );
00241             return _value;
00242         }
00243 
00244       /// Check if an iterator is valid.
00245       /**
00246         * This implements the corresponding method of the base class.
00247         *
00248         * @see CdbIItr::isValid()
00249         */
00250         virtual bool isValid( )
00251         {
00252             return _isValid;
00253         }
00254 
00255       /// Make a clone of itself
00256       /**
00257         * @see CdbIItr::clone()
00258         */
00259         virtual InterfaceType* clone( ) const
00260         {
00261             return new CombinedIntervalIterator( *this );
00262         }
00263 
00264     private:
00265 
00266       // Parameters of the iterator
00267 
00268         CdbRooRoViCollectionR _viCollection;
00269         CdbRooRoOiCollectionR _oiCollection;
00270 
00271         BdbTime _beginTime;
00272         BdbTime _endTime;
00273 
00274       // The state of the iterator
00275 
00276         bool _isValid;
00277         bool _hasEverBeenAdvanced;
00278 
00279         CdbRooRoCi _value;
00280 
00281         CdbRooRoViCollectionR::IteratorOfIntervals _viItr;
00282     };
00283 };
00284 
00285 /////////////////////////////
00286 // Class: CdbRooRoMetaDataR //
00287 /////////////////////////////
00288 
00289 CdbRooRoMetaDataR::CdbRooRoMetaDataR( const BdbTime& theMinValidityTime,
00290                                       const BdbTime& theMaxValidityTime,
00291                                       const BdbTime& theMinInsertionTime ) :
00292     CdbRooRoPersistentCollectionR( ),
00293     _minValidityTime (theMinValidityTime),
00294     _maxValidityTime (theMaxValidityTime),
00295     _minInsertionTime(theMinInsertionTime),
00296     _maxInsertionTime(BdbTime::plusInfinity),
00297     _modified        (theMinInsertionTime)
00298 { }
00299 
00300 CdbRooRoMetaDataR::CdbRooRoMetaDataR( const BdbTime&                theMinValidityTime,
00301                                       const BdbTime&                theMaxValidityTime,
00302                                       const BdbTime&                theMinInsertionTime,
00303                                       const BdbTime&                theMaxInsertionTime,
00304                                       const BdbTime&                theModificationTime,
00305                                       const CdbRooRoOiCollectionR&  theOriginalCollection,
00306                                       const CdbRooRoRevCollectionR& theRevisionCollection ) :
00307     CdbRooRoPersistentCollectionR( ),
00308     _minValidityTime   (theMinValidityTime),
00309     _maxValidityTime   (theMaxValidityTime),
00310     _minInsertionTime  (theMinInsertionTime),
00311     _maxInsertionTime  (theMaxInsertionTime),
00312     _modified          (theModificationTime),
00313     _originalCollection(theOriginalCollection),
00314     _revCollection     (theRevisionCollection)
00315 { }
00316 
00317 CdbCPtr< CdbRooRoOiCollectionR>
00318 CdbRooRoMetaDataR::originalIntervalsCollection( ) const
00319 {
00320     return CdbCPtr< CdbRooRoOiCollectionR>( new CdbRooRoOiCollectionR( _originalCollection ));
00321 }
00322 
00323 CdbStatus
00324 CdbRooRoMetaDataR::findByRevision( const BdbTime& theRevisionId,
00325                                    const BdbTime& theValidityTime,
00326                                    CdbRooRoOiR&   theOriginalInterval,
00327                                    BdbTime&       theBeginOfVisiblePeriod,
00328                                    BdbTime&       theEndOfVisiblePeriod ) const
00329 {
00330     const char* errorStr = "CdbRooRoMetaDataR::findByRevision() -- ERROR";
00331     const char* fatalStr = "CdbRooRoMetaDataR::findByRevision() -- FATAL INTERNAL ERROR!!!";
00332 
00333     CdbStatus result = CdbStatus::Error;
00334     do {
00335 
00336       // This is required by the public contract of the method.
00337 
00338         theBeginOfVisiblePeriod = minValidity( );
00339         theEndOfVisiblePeriod   = maxValidity( );
00340 
00341       // Verify the parameters
00342 
00343         if(( theValidityTime <  minValidity( )) ||
00344            ( theValidityTime >= maxValidity( ))) {
00345             cout << errorStr << endl
00346                  << "    The passed validity time is out of the validity window" << endl
00347                  << "    of the current metadata object." << endl;
00348             break;
00349         }
00350 
00351       // Get to the specified revision, and then to the collection
00352       // of "visible" intervals.
00353 
00354         CdbRooRoRevisionR revision;
00355         if( CdbStatus::Success != _revCollection.find( theRevisionId,
00356                                                        revision )) {
00357             cout << errorStr << endl
00358                  << "    Specified revision was not found in the collection." << endl
00359                  << "        PASSED REVISION ID: " << CdbTimeUtils::time2string( theRevisionId ) << endl;
00360             break;
00361         }
00362 
00363       // Find a "visible" interval through the "visible" collection.
00364       //
00365       // IMPORTANT NOTE:
00366       //
00367       //     This operation if successfull will return us a short description
00368       //     of visible interval. The "successful" may also mean 0 index. No matter what
00369       //     is the value of the original interval's index carried by the visible interval
00370       //     still we have very important information about the visible validity range of
00371       //     the found index. If this ois 0 index the we have the visible validity interval
00372       //     of a 'hole', and if it's not then its the interval of an actual object.
00373       //
00374       //     Assigning the correct value to the visible validity interval is required
00375       //     by the contract of the current method.
00376 
00377         CdbRooRoViR viInterval;
00378 
00379         if( !revision.collection( ).find( viInterval, theValidityTime )) {
00380 
00381             assert( 0 );    // Inconsistent TimeLine. All range of the insertion time
00382                             // must be covered.
00383             break;
00384         }
00385 
00386         theBeginOfVisiblePeriod = viInterval.begin( );
00387         theEndOfVisiblePeriod   = viInterval.end( );
00388 
00389         UInt_t oiIdx = viInterval.value( );         // Get to the index of the 'original' interval
00390         if( 0 == oiIdx ) {
00391             result = CdbStatus::NotFound;
00392             break;
00393         }
00394 
00395       // Extract the "original" interval information and setup the values
00396       // of parameters to be returned.
00397 
00398         BdbTime beginOfDurationPeriod( 0 );     // Don't need this information
00399         BdbTime endOfDurationPeriod  ( 0 );     // Don't need this information
00400 
00401         if( CdbStatus::Success != _originalCollection.find( oiIdx,
00402                                                             theOriginalInterval,
00403                                                             beginOfDurationPeriod,
00404                                                             endOfDurationPeriod )) {
00405             cout << fatalStr << endl
00406                  << "    The collection of 'visible' intervals does not match" << endl
00407                  << "    the collection of 'original' intervals." << endl;
00408 
00409             assert( 0 );    // FATAL INTERNAL ERROR!!!!
00410 
00411             break;
00412         }
00413 
00414       // Done
00415 
00416         result = CdbStatus::Success;
00417 
00418     } while( false );
00419     
00420     return result;
00421 }
00422 
00423 CdbStatus
00424 CdbRooRoMetaDataR::findByRevision( const char*    theRevisionName,
00425                                    const BdbTime& theValidityTime,
00426                                    CdbRooRoOiR&   theOriginalInterval,
00427                                    BdbTime&       theBeginOfVisiblePeriod,
00428                                    BdbTime&       theEndOfVisiblePeriod ) const
00429 {
00430     const char* errorStr = "CdbRooRoMetaDataR::findByRevision() -- ERROR";
00431 
00432     CdbStatus result = CdbStatus::Error;
00433     do {
00434 
00435       // This is required by the public contract of the method.
00436 
00437         theBeginOfVisiblePeriod = minValidity( );
00438         theEndOfVisiblePeriod   = maxValidity( );
00439 
00440       // Do not verify anything - just find a revision by name
00441       // and do the rest through the similar procedure.
00442 
00443         BdbTime revisionId( 0 );
00444 
00445         if( 0 == theRevisionName ) {
00446             revisionId = BdbTime::plusInfinity;     // TOPMOST revision
00447         } else {
00448             CdbRooRoRevisionR revision;
00449             if( CdbStatus::Success != _revCollection.find( theRevisionName,
00450                                                            revision )) {
00451                 cout << errorStr << endl
00452                      << "    Specified revision was not found in the collection." << endl
00453                      << "        PASSED REVISION NAME: \"" << theRevisionName << "\"" << endl;
00454                 break;
00455             }
00456             revisionId = revision.id( );
00457         }
00458 
00459       // Proceed to the actual finder...
00460 
00461         result = findByRevision( revisionId,
00462                                  theValidityTime,
00463                                  theOriginalInterval,
00464                                  theBeginOfVisiblePeriod,
00465                                  theEndOfVisiblePeriod );
00466 
00467     } while( false );
00468     
00469     return result;
00470 }
00471 
00472 CdbStatus
00473 CdbRooRoMetaDataR::findByInsertion( const BdbTime& theInsertionTime,
00474                                     const BdbTime& theValidityTime,
00475                                     CdbRooRoOiR&   theOriginalInterval,
00476                                     BdbTime&       theBeginOfDurationPeriod,
00477                                     BdbTime&       theEndOfDurationPeriod ) const
00478 {
00479     const char* errorStr = "CdbRooRoMetaDataR::findByInsertion() -- ERROR";
00480 
00481     CdbStatus result = CdbStatus::Error;
00482     do {
00483 
00484       // Verify the parameters
00485 
00486         if(( theValidityTime <  minValidity( )) ||
00487            ( theValidityTime >= maxValidity( ))) {
00488             cout << errorStr << endl
00489                  << "    The passed validity time is out of the validity window" << endl
00490                  << "    of the current metadata object." << endl;
00491             break;
00492         }
00493         if(( theInsertionTime <  minInsertion( )) ||
00494            ( theInsertionTime >= maxInsertion( ))) {
00495             cout << errorStr << endl
00496                  << "    The passed insertion time is out of the insertion window" << endl
00497                  << "    of the current metadata object." << endl;
00498             break;
00499         }
00500 
00501       // Find the "original" interval and its "duration" interval through
00502       // the "original" collection.
00503       //
00504       // NOTE: We preserve the returned status since it may also be equal
00505       //       to CdbStatus::NotFound if the 0-0-0-0 reference found instead
00506       //       of an actual object.
00507 
00508         CdbStatus status = _originalCollection.find( theInsertionTime,
00509                                                      theOriginalInterval,
00510                                                      theBeginOfDurationPeriod,
00511                                                      theEndOfDurationPeriod );
00512         if( CdbStatus::Success != status ) {
00513             result = status;
00514             break;
00515         }
00516 
00517       // Check if the specified "validity" time falls into the "original"
00518       // "validity" of this interval.
00519 
00520         if(( theValidityTime <  theOriginalInterval.begin( )) ||
00521            ( theValidityTime >= theOriginalInterval.end( )   )) {
00522             cout << errorStr << endl
00523                  << "    This is inappropriate use of this finding method since" << endl
00524                  << "    the passed validity time does not fall into the 'validity' period" << endl
00525                  << "    of found 'original' interval." << endl;
00526             break;
00527         }
00528 
00529       // Done
00530 
00531         result = CdbStatus::Success;
00532 
00533     } while( false );
00534     
00535     return result;
00536 }
00537 CdbStatus
00538 CdbRooRoMetaDataR::findRevision( const BdbTime&     theId,
00539                                  CdbRooRoRevisionR& theRef ) const
00540 {
00541     CdbStatus result = CdbStatus::NotFound;
00542     do {
00543 
00544       // Check if the specified revision identifier time falls into
00545       // the "window" of current metadata object.
00546       //
00547       // NOTE: Passing +Infinity is allowed.
00548 
00549         if( theId < minInsertion( )) break;
00550         if(( BdbTime::plusInfinity != maxInsertion( )) && ( theId >= maxInsertion( ))) break;
00551 
00552       // Delegate revision lookup down to the revisions collection
00553 
00554         result = _revCollection.find( theId,
00555                                       theRef );
00556     } while( false );
00557 
00558     return result;
00559 }
00560 
00561 CdbStatus
00562 CdbRooRoMetaDataR::findRevision( const BdbTime&                theId,
00563                                  CdbCPtr< CdbRooRoRevisionR >& thePtr ) const
00564 {
00565     CdbStatus result = CdbStatus::Error;
00566     {
00567         CdbRooRoRevisionR revision;
00568         if( CdbStatus::Success == ( result = findRevision( theId,
00569                                                            revision ))) thePtr = new CdbRooRoRevisionR( revision );
00570     }
00571     return result;
00572 }
00573 
00574 CdbStatus
00575 CdbRooRoMetaDataR::findRevision( const char*        theName,
00576                                  CdbRooRoRevisionR& theRef ) const
00577 {
00578     const char* errorStr = "CdbRooRoMetaDataR::findRevision(name) -- ERROR";
00579 
00580     CdbStatus result = CdbStatus::NotFound;
00581     do {
00582 
00583       // Verify parameters
00584 
00585         if( 0 == theName ) {
00586             cout << errorStr << endl
00587                  << "    Null pointer passed instead of a valid revision name." << endl;
00588             break;
00589         }
00590 
00591       // Delegate revision lookup down to the revisions collection
00592 
00593         result = _revCollection.find( theName,
00594                                       theRef );
00595     } while( false );
00596 
00597     return result;
00598 }
00599 
00600 CdbStatus
00601 CdbRooRoMetaDataR::findRevision( const char*                   theName,
00602                                  CdbCPtr< CdbRooRoRevisionR >& thePtr ) const
00603 {
00604     CdbStatus result = CdbStatus::Error;
00605     {
00606         CdbRooRoRevisionR revision;
00607         if( CdbStatus::Success == ( result = findRevision( theName,
00608                                                            revision ))) thePtr = new CdbRooRoRevisionR( revision );
00609     }
00610     return result;
00611 }
00612 
00613 CdbStatus
00614 CdbRooRoMetaDataR::revisionIdIterator( CdbItr<BdbTime>& theItr ) const
00615 {
00616     theItr = _revCollection.iterator_identifiers( );
00617     return CdbStatus::Success;
00618 }
00619 
00620 CdbStatus
00621 CdbRooRoMetaDataR::revisionNameIterator( CdbItr<const char*>& theItr ) const
00622 {
00623     theItr = _revCollection.iterator_names( );
00624     return CdbStatus::Success;
00625 }
00626 
00627 bool
00628 CdbRooRoMetaDataR::verifyObjectIteratorParameters( const BdbTime& theBeginTime,
00629                                                    const BdbTime& theEndTime ) const
00630 {
00631     const char* errorStr = "CdbRooRoMetaDataR::verifyObjectIteratorParameters() -- ERROR";
00632 
00633     bool result = false;
00634     do {
00635 
00636       // See formal requirements at the class's description
00637 
00638         if( ! (( minValidity( ) <= theBeginTime ) && ( theBeginTime < maxValidity( )))) {
00639             cout << errorStr << endl
00640                  << "    Incorrect begin time passed to the method. It's out of the validity" << endl
00641                  << "    time window of the current meta-data object." << endl
00642                  << "        PASSED BEGIN TIME : " << CdbTimeUtils::time2string( theBeginTime ) << endl
00643                  << "        WINDOW BEGIN TIME : " << CdbTimeUtils::time2string( minValidity( )) << endl
00644                  << "        WINDOW END   TIME : " << CdbTimeUtils::time2string( maxValidity( )) << endl;
00645             break;
00646         }
00647         if( ! (( minValidity( ) < theEndTime ) && ( theEndTime <= maxValidity( )))) {
00648             cout << errorStr << endl
00649                  << "    Incorrect end time passed to the method. It's out of the validity" << endl
00650                  << "    time window of the current meta-data object." << endl
00651                  << "        PASSED END   TIME : " << CdbTimeUtils::time2string( theEndTime ) << endl
00652                  << "        WINDOW BEGIN TIME : " << CdbTimeUtils::time2string( minValidity( )) << endl
00653                  << "        WINDOW END   TIME : " << CdbTimeUtils::time2string( maxValidity( )) << endl;
00654             break;
00655         }
00656         if(  ! ( theBeginTime < theEndTime )) {
00657             cout << errorStr << endl
00658                  << "    Incorrect begin and end times passed to the method." << endl
00659                  << "    The begin time must be strictly less (older) than the end one. " << endl
00660                  << "        PASSED BEGIN TIME : " << CdbTimeUtils::time2string( theBeginTime ) << endl
00661                  << "        PASSED END   TIME : " << CdbTimeUtils::time2string( theEndTime ) << endl;
00662             break;
00663         }
00664 
00665       // Done
00666 
00667         result = true;
00668 
00669     } while( false );
00670 
00671     return result;
00672 }
00673 
00674 CdbStatus
00675 CdbRooRoMetaDataR::objectIterator( CdbItr<CdbRooRoCi>& theItr,
00676                                    const BdbTime&      theRevisionId,
00677                                    const BdbTime&      theBeginTime,
00678                                    const BdbTime&      theEndTime ) const
00679 {
00680     const char* errorStr = "CdbRooRoMetaDataR::objectIterator(id) -- ERROR";
00681 
00682     CdbStatus result = CdbStatus::Error;
00683     do {
00684 
00685         if( !verifyObjectIteratorParameters( theBeginTime,
00686                                              theEndTime )) break;
00687       // Find revision
00688 
00689         CdbRooRoRevisionR revision;
00690         if( CdbStatus::Success != findRevision( theRevisionId,
00691                                                 revision )) {
00692             cout << errorStr << endl
00693                  << "    Failed to find a revision for specified identifier." << endl
00694                  << "        REVISION IDENTIFIER : " << CdbTimeUtils::time2string( theRevisionId ) << endl;
00695         }
00696 
00697       // ATTENTION: This is not a memory leak - the created object
00698       //            will be destroyed by the iterator.
00699 
00700         theItr = CdbItr<CdbRooRoCi>( new CombinedIntervalIterator( revision.collection( ),
00701                                                                   _originalCollection,
00702                                                                   theBeginTime,
00703                                                                   theEndTime ));
00704 
00705       // Done
00706 
00707         result = CdbStatus::Success;
00708 
00709     } while( false );
00710 
00711     return result;
00712 }
00713 
00714 CdbStatus
00715 CdbRooRoMetaDataR::objectIterator( CdbItr<CdbRooRoCi>& theItr,
00716                                    const char*         theName,
00717                                    const BdbTime&      theBeginTime,
00718                                    const BdbTime&      theEndTime ) const
00719 {
00720     const char* errorStr = "CdbRooRoMetaDataR::objectIterator(name) -- ERROR";
00721 
00722     CdbStatus result = CdbStatus::Error;
00723     do {
00724 
00725         if( !verifyObjectIteratorParameters( theBeginTime,
00726                                              theEndTime )) break;
00727 
00728       // Find revision
00729 
00730         CdbRooRoRevisionR revision;
00731         if( CdbStatus::Success != findRevision( theName,
00732                                                 revision )) {
00733             cout << errorStr << endl
00734                  << "    Failed to find a revision for specified name." << endl
00735                  << "        REVISION NAME : \"" << theName << "\"" << endl;
00736             break;
00737         }
00738 
00739       // ATTENTION: This is not a memory leak - the created object
00740       //            will be destroyed by the iterator.
00741 
00742         theItr = CdbItr<CdbRooRoCi>( new CombinedIntervalIterator( revision.collection( ),
00743                                                                    _originalCollection,
00744                                                                    theBeginTime,
00745                                                                    theEndTime ));
00746 
00747       // Done
00748 
00749         result = CdbStatus::Success;
00750 
00751     } while( false );
00752 
00753     return result;
00754 }
00755 
00756 void
00757 CdbRooRoMetaDataR::dump( std::ostream& o ) const
00758 {
00759     o << "MIN.VALIDITY           : " << CdbTimeUtils::time2string( minValidity ( )) << " : " << minValidity ( ) << endl
00760       << "MAX.VALIDITY           : " << CdbTimeUtils::time2string( maxValidity ( )) << " : " << maxValidity ( ) << endl
00761       << "MIN.INSERTION          : " << CdbTimeUtils::time2string( minInsertion( )) << " : " << minInsertion( ) << endl
00762       << "MAX.INSERTION          : " << CdbTimeUtils::time2string( maxInsertion( )) << " : " << maxInsertion( ) << endl
00763       << "MODIFIED               : " << CdbTimeUtils::time2string( modified    ( )) << " : " << modified    ( ) << endl
00764       << "NUM.ORIGINAL INTERVALS : " << _originalCollection.size( ) << endl
00765       << "NUM.REVISIONS          : " << _revCollection.size( ) << endl;
00766 }
00767 
00768 CdbStatus
00769 CdbRooRoMetaDataR::storeSubCollectionsAt( const CdbRooRoCollectionAddressR& theCollectionAddress,
00770                                           const CdbCPtr<TFile>&             theFilePtr,
00771                                           Int_t&                            theNumBytesStored )
00772 {
00773     const char* errorStr = "CdbRooRoMetaDataR::storeSubCollectionsAt() -- ERROR";
00774 
00775     Int_t numBytesStored = 0;
00776 
00777   // Store the embedded colletions.
00778 
00779     Int_t numBytes = 0;
00780 
00781     CdbStatus status = CdbStatus::Error;
00782 
00783     if( CdbStatus::Success != ( status = _originalCollection.storeAsEmbeddedAt( theCollectionAddress,
00784                                                                                 theFilePtr,
00785                                                                                 numBytes ))) {
00786         ErrMsg(error) << errorStr << endl
00787                       << "   Failed to store an embedded collection of original intervals." << endl
00788                       << "       File Name         : " << theFilePtr->GetName( ) << endl
00789                       << "       Collection Address: " << theCollectionAddress   << endl
00790                       << "       Error Status      : " << status
00791                       << endmsg;
00792         return status;
00793     }
00794     numBytesStored += numBytes;
00795 
00796     if( CdbStatus::Success != ( status = _revCollection.storeAsEmbeddedAt( theCollectionAddress,
00797                                                                            theFilePtr,
00798                                                                            numBytes ))) {
00799         ErrMsg(error) << errorStr << endl
00800                       << "   Failed to store an embedded collection of revisions." << endl
00801                       << "       File Name         : " << theFilePtr->GetName( ) << endl
00802                       << "       Collection Address: " << theCollectionAddress   << endl
00803                       << "       Error Status      : " << status
00804                       << endmsg;
00805         return status;
00806     }
00807     numBytesStored += numBytes;
00808 
00809   // Done
00810 
00811     theNumBytesStored = numBytesStored;
00812 
00813     return CdbStatus::Success;
00814 }
00815 
00816 /////////////////
00817 // End Of File //
00818 /////////////////

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