00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "BaBar/BaBar.hh"
00011
00012 #include "CdbBase/CdbAnyTypeDict.hh"
00013
00014 #include <iostream>
00015 using std::cout;
00016 using std::endl;
00017 #include <string>
00018 using std::string;
00019
00020 namespace {
00021 void exit_if( bool flag ) { if( flag ) std::exit( 1 ); }
00022 struct A {
00023 explicit A(const string& theStr = "") : str(theStr) { }
00024 string str;
00025 };
00026 }
00027
00028 int
00029 main( int argc, char* argv[] )
00030 {
00031 cout << "d1" << endl;
00032 CdbAnyTypeDict<string> d1;
00033 exit_if( !d1.empty( ));
00034 {
00035 cout << " d2" << endl;
00036 CdbAnyTypeDict<string> d2;
00037 float f1 = 1.234;
00038 exit_if( CdbStatus::Success != d2.insert( "float", f1 ));
00039 cout << " finding in d2..." << endl;
00040 float f2 = 0.0;
00041 exit_if( CdbStatus::Success != d2.find( "float", f2 ));
00042 cout << " f1 = " << f1 << "\n"
00043 << " f2 = " << f2 << endl;
00044 cout << " d1 = d2" << endl;
00045 d1 = d2;
00046 cout << " ~d2" << endl;
00047 }
00048 exit_if( CdbStatus::Success != d1.insert( "A", A( "Value of A" )));
00049 cout << "finding in d1..." << endl;
00050 cout << " d1.exists( \"A\" ) = " << d1.exists( "A" ) << endl;
00051 cout << " d1.exists( \"B\" ) = " << d1.exists( "B" ) << endl;
00052 float f3 = 0.0;
00053 exit_if( CdbStatus::Success != d1.find( "float", f3 ));
00054 cout << " f3 = " << f3 << endl;
00055 A a;
00056 exit_if( CdbStatus::Success != d1.find( "A", a ));
00057 cout << " a.str = \"" << a.str << "\"" << endl;
00058 cout << "~d1" << endl;
00059 float f4 = 2.73;
00060 cout << "replacing \"float\" in d1 with " << f4 << endl;
00061 exit_if( CdbStatus::Success != d1.replace( "float", f4 ));
00062 cout << "replacing \"float\" in d1..." << endl;
00063 f4 = 0.0;
00064 exit_if( CdbStatus::Success != d1.find( "float", f4 ));
00065 cout << " f4 = " << f4 << endl;
00066 return 0;
00067 }
00068
00069
00070
00071