Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / Advanced / ch_3 / client.cpp
blobda08acc1d2e66d3f61cb784d2769f2d93f36025a
2 //=============================================================================
3 /**
4 * @file client.cpp
6 * @author Source code used in TAO has been modified and adapted from thecode provided in the book
7 * @author "Advanced CORBA Programming with C++"by Michi Henning and Steve Vinoski. Copyright1999. Addison-Wesley
8 * @author Reading
9 * @author MA. Used with permission ofAddison-Wesley.Modified for TAO by Mike Moran <mm4@cs.wustl.edu>
11 //=============================================================================
14 #include "timeC.h"
15 #include <ace/streams.h>
17 // The following header is #included automatically by ACE+TAO.
18 // Therefore, they don't need to be included explicitly.
19 //#include <iostream.h>
21 int
22 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
24 try
26 // Check arguments
27 if (argc != 2)
29 cerr << "Usage: client IOR_string" << endl;
30 throw 0;
33 // Initialize orb
34 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
36 // Destringify argv[1]
37 CORBA::Object_var obj = orb->string_to_object (argv[1]);
38 if (CORBA::is_nil (obj.in ()))
40 cerr << "Nil Time reference" << endl;
41 throw 0;
44 // Narrow
45 Time_var tm = Time::_narrow (obj.in ());
47 if (CORBA::is_nil (tm.in ()))
49 cerr << "Argument is not a Time reference" << endl;
50 throw 0;
54 cout << "Validating connection"<<endl;
55 CORBA::PolicyList_var pols;
56 tm->_validate_connection (pols.out ());
57 cout << "Succesfull " <<endl;
59 // Get time
60 TimeOfDay tod = tm->get_gmt ();
61 cout << "Time in Greenwich is "
62 << setw (2) << setfill ('0') << tod.hour << ":"
63 << setw (2) << setfill ('0') << tod.minute << ":"
64 << setw (2) << setfill ('0') << tod.second << endl;
66 catch (const CORBA::Exception &x)
68 x._tao_print_exception ("Who is the culprit\n");
69 cerr << "Uncaught CORBA exception" << endl;
70 return 1;
72 catch (...)
74 return 1;
76 return 0;