Here is a C++ program that can be used as the client of this Three Tier System:
0814: #include <iostream.h> 0815: #include <stdlib.h> 0816: #include <OB/CORBA.h> 0817: #include <OB/CosNaming.h> 0818: #include <AgesDB.h> 0819: int main(int argc, char* argv[], char*[]) { 0820: try { 0821: CORBA_ORB_var orb = CORBA_ORB_init(argc, argv); 0822: CORBA_BOA_var boa = orb -> BOA_init(argc, argv); 0823: CORBA_Object_var objRef = orb -> string_to_object(argv[1]); 0824: CosNaming_NamingContext_var ncRef = 0825: CosNaming_NamingContext::_narrow(objRef); 0826: CosNaming_Name path; 0827: path.length(1); 0828: path[0].id = CORBA_string_dup("AgesDB"); 0829: path[0].kind = CORBA_string_dup(""); 0830: AgesDBApp_AgesDB_var stubAgesDB = 0831: AgesDBApp_AgesDB::_narrow(ncRef -> resolve(path)); 0832: char stdinLine[100]; 0833: char in_last[10]; 0834: char in_first[10]; 0835: char in_age[10]; 0836: char *out_firstptr = 0; 0837: char *out_ageptr = 0; 0838: bool stillMoreRequests = true; 0839: while ( stillMoreRequests ) { 0840: cout << "agqr: "; cin >> stdinLine; 0841: switch ( stdinLine[0] ) { 0842: case 'a': 0843: cout << "last: "; cin >> in_last; 0844: cout << "first: "; cin >> in_first; 0845: cout << "age: "; cin >> in_age; 0846: stubAgesDB -> addPerson(in_last, in_first, in_age); 0847: break; 0848: case 'g': 0849: cout << "last: "; cin >> in_last; 0850: stubAgesDB -> getPerson(in_last, out_firstptr, out_ageptr); 0851: cout << out_firstptr << " " << out_ageptr << endl; 0852: break; 0853: case 'q': 0854: stillMoreRequests = false; 0855: break; 0856: case 'r': 0857: cout << "last: "; cin >> in_last; 0858: stubAgesDB -> removePerson(in_last); 0859: break; 0860: default: 0861: break; 0862: } 0863: } 0864: } 0865: catch ( ... ) { 0866: cout << "whoops" << endl; 0867: } 0868: }With the help of OmniBroker, this C++ program can be compiled and executed in a similar way to the C++ program given earlier.