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

CdbBdbObjectConvertor.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbObjectConvertor.cc,v 1.12 2004/08/06 05:54:18 bartoldu Exp $
00003 #include "BaBar/BaBar.hh"
00004 
00005 /// The implementation of the CdbBdbObjectConvertor class.
00006 /**
00007   * @see CdbBdbObjectConvertor
00008   */
00009 
00010 #include "CdbBdb/CdbBdbObjectConvertor.hh"
00011 
00012 #include "CdbBase/Cdb.hh"
00013 #include "CdbBase/CdbDatabase.hh"
00014 #include "CdbBase/CdbCondition.hh"
00015 #include "CdbBase/CdbObject.hh"
00016 
00017 #include "CdbBdb/CdbBdb.hh"
00018 #include "CdbBdb/CdbBdbObject.hh"
00019 
00020 #include <string.h>
00021 #include <iostream>
00022 using std::cout;
00023 using std::endl;
00024 
00025 CdbStatus
00026 CdbBdbObjectConvertor::narrow( BdbHandle(BdbObject)& thePersObj,
00027                                const CdbObjectPtr&   thePtr )
00028 {
00029     CdbStatus result = CdbStatus::Error;
00030 
00031     do {
00032 
00033       // Find a pointer onto the database singleton.
00034 
00035         CdbPtr cdbPtr = thePtr->parent( )->parentDatabase( )->parent( );
00036         if( cdbPtr.isNull( )) break;
00037 
00038       // Check if the object pointer points onto an object corresponding
00039       // to the right technology.
00040 
00041         const char* objectTechnology  = cdbPtr->technologyName( );
00042 
00043         if( 0 != strcmp( CdbBdb::technology( ),
00044                          objectTechnology )) {
00045 
00046             cout << "CdbBdbObjectConvertor::narrow() -- ERROR." << endl
00047                  << "    The object pointer passed into this procedure does not" << endl
00048                  << "    match the expected database technology." << endl
00049                  << "        EXPECTED: \"" << CdbBdb::technology( ) << "\"" << endl
00050                  << "        FOUND:    \"" << objectTechnology      << "\"" << endl;
00051             break;
00052         }
00053 
00054       // Get to the right dynamic type and extract the value from it.
00055 
00056         CdbBdbObject* oPtr = dynamic_cast<CdbBdbObject*>( thePtr.get( ));
00057         thePersObj = oPtr->objectRef( );
00058 
00059         result = CdbStatus::Success;
00060 
00061     } while( false );
00062 
00063     return result;
00064 }
00065 
00066 /////////////////
00067 // End Of File //
00068 /////////////////

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