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

CdbBdbSOriginCollectionP.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbSOriginCollectionP.cc,v 1.7 2004/08/06 05:54:25 bartoldu Exp $
00003 
00004 /// The implementation file for the CdbBdbSOriginCollectionP class
00005 /**
00006   * @see CdbBdbSOriginCollectionP
00007   */
00008 
00009 #include "BaBar/BaBar.hh"
00010 
00011 #include "CdbBdbShared/CdbBdbSOriginCollectionP.hh"
00012 #include "CdbBdbShared/CdbBdbSOriginP.hh"
00013 
00014 #include <iostream>
00015 #include <assert.h>
00016 using std::cout;
00017 using std::endl;
00018 
00019 CdbBdbSOriginCollectionP::CdbBdbSOriginCollectionP( ) :
00020     CdbBdbSCollectionP( )
00021 { }
00022 
00023 CdbBdbSOriginCollectionP::~CdbBdbSOriginCollectionP( ) 
00024 { }
00025 
00026 CdbStatus
00027 CdbBdbSOriginCollectionP::insert( const BdbRef( CdbBdbSCollectionElementP )& theRef )
00028 {
00029     const char* errorStr = "CdbBdbSOriginCollectionP::insert() -- ERROR";
00030     const char* fatalStr = "CdbBdbSOriginCollectionP::insert() -- FATAL ERROR";
00031 
00032     CdbStatus result = CdbStatus::Error;
00033     do {
00034 
00035       // Get back to the original class.
00036 
00037         BdbRef(CdbBdbSOriginP) theOriginRef = (const BdbRef(CdbBdbSOriginP)&) theRef;
00038 
00039       // Verify parameters.
00040 
00041       // Check if it's the very first MASTER origin to be inserted
00042       // into this collection.
00043 
00044         if( CdbBdbSOriginP::MASTER == theOriginRef->type( )) {
00045 
00046             IteratorOfIdentifiers itr = iterator_identifiers( );
00047             while( itr.next( ) && itr.isValid( )) {
00048 
00049                 BdbRef(CdbBdbSOriginP) cRef;
00050                 if( CdbStatus::Success != find( itr.value( ), cRef )) {
00051 
00052                     cout << fatalStr << endl
00053                          << "    Internal error. The current collection is ast the inconsistent" << endl
00054                          << "    state since at least one element is missing." << endl;
00055 
00056                     assert( 0 );
00057                 
00058                     break;
00059                 }
00060                 if( CdbBdbSOriginP::MASTER == cRef->type( )) {
00061                     cout << errorStr << endl
00062                          << "    The current collection already has the MASTER origin." << endl
00063                          << "    Only one MASTER origin is allowed in the collection." << endl;
00064                     break;
00065                 }
00066             }
00067         }
00068 
00069       // Do the rest at the base class's method.
00070 
00071         result = CdbBdbSCollectionP::insert( theRef );
00072 
00073     } while( false );
00074 
00075     return result;
00076 }
00077 
00078 /////////////////
00079 // End Of File //
00080 /////////////////

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