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

CdbBdb2RooPayloadCompare.cc

Go to the documentation of this file.
00001 // A dual-technology test application
00002 /**
00003   * This simple program is meant to illustrate a proper use of extended CDB API
00004   * parameters to load two objects stored using different technologies.
00005   *
00006   * The program can also be used to get an idea how to build a comparision procedure
00007   * for the payload of converted database installations based on the "Bdb" and "Roo"
00008   * technologies.
00009   *
00010   * To run the program there following environment variables have to be set to point
00011   * onto the corresponding database installations:
00012   *
00013   *     OO_FD_BOOT   - for an Objectivity/DB federation
00014   *     CDB_ROO_BOOT - for a converted ROOT I/O based database installation
00015   *
00016   * The program must be run with one parameter - a name of a condition to be
00017   * inspected in both technologies. Don't forget to put into quotes to avoid
00018   * problems with a UNIX shell.
00019   * 
00020   */
00021 #include "BaBar/BaBar.hh"
00022 
00023 #include "CdbBase/CdbTransaction.hh"
00024 #include "CdbBase/CdbCondition.hh"
00025 #include "CdbBase/CdbObject.hh"
00026 #include "CdbBase/CdbTimeUtils.hh"
00027 #include "CdbBase/CdbEnvironment.hh"
00028 
00029 #include "CdbBdbShared/CdbBdbShared.hh"
00030 
00031 #include "CdbRooReadonly/CdbRooReadonly.hh"
00032 
00033 #include <iostream>
00034 #include <string>
00035 using std::cout;
00036 using std::cerr;
00037 using std::endl;
00038 
00039 int
00040 main( int argc, char* argv[] )
00041 {
00042   // Parameters of conditions to be found
00043 
00044     if( argc != 2 ) {
00045         cout << "Usage: <condition>" << endl;
00046         return 1;
00047     }
00048     const char* conditionName = argv[1];
00049 
00050     const char* useDefaultViewName     = 0;     // an actual name will depend on a technology
00051     const char* useDefaultDatabaseName = 0;     // an actual name will depend on a technology
00052 
00053     BdbTime validityTime( BdbTime::now( ));
00054 
00055   // Make sure both CDB API implementations are linked by the application and loaded
00056   // into a dictionary of the API implementations.
00057 
00058 
00059     CdbRooReadonly::forceLoad( );
00060     CdbBdbShared::forceLoad( );
00061 
00062   // This is just a test
00063 
00064     if( CdbStatus::Success != CdbEnvironment::setDefaultPath( "<local>::<recent>",
00065                                                               "<default>",
00066                                                               "Readonly",
00067                                                               "Roo" )) {
00068         cerr << "failed to set default parameters of the CDB API." << endl;
00069         return 1;
00070     }
00071 
00072   // Start two transactions in contexts of both technologies.
00073 
00074     CdbTransaction readOnlyTransactionForBdb( "Bdb", "Shared" );
00075     CdbTransaction readOnlyTransactionForRoo( "Roo", "Readonly" );
00076 
00077   // Find the condition API objects for both technologies
00078 
00079     CdbConditionPtr bdbConditionPtr;
00080     if( CdbStatus::Success != CdbCondition::instance( bdbConditionPtr,
00081                                                       conditionName,
00082                                                       useDefaultViewName,
00083                                                       useDefaultDatabaseName,
00084                                                       "Shared",
00085                                                       "Bdb" )) return 1;
00086 
00087     CdbConditionPtr rooConditionPtr;
00088     if( CdbStatus::Success != CdbCondition::instance( rooConditionPtr,
00089                                                       conditionName,
00090                                                       useDefaultViewName,
00091                                                       useDefaultDatabaseName,
00092                                                       "Readonly",
00093                                                       "Roo" )) return 1;
00094 
00095   // Find two objects from each condition
00096 
00097     CdbObjectPtr bdbObjectPtr;
00098     if( CdbStatus::Success != bdbConditionPtr->findObject( bdbObjectPtr,
00099                                                            validityTime )) return 1;
00100 
00101     CdbObjectPtr rooObjectPtr;
00102     if( CdbStatus::Success != rooConditionPtr->findObject( rooObjectPtr,
00103                                                            validityTime )) return 1;
00104 
00105   // Report object identity & types for found objects
00106 
00107     cout << "BDB: found object id = " << bdbObjectPtr->id( ) << ", type = \"" << bdbObjectPtr->type( ) << "\"" << endl
00108          << "ROO: found object id = " << rooObjectPtr->id( ) << ", type = \"" << rooObjectPtr->type( ) << "\"" << endl;
00109 
00110   // An optional step: at this point the found technology-neitral objects (CdbObjectPtr)
00111   // can be turned into technology specific ones using the corresponding conversion facilities
00112   // from "CdbBdb" amd "CdbRoo" packages.
00113 
00114     ;
00115 
00116     return 0;
00117 }
00118 
00119 /////////////////
00120 // End Of File //
00121 /////////////////

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