Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / IDL_Inherited_Operation / client.cpp
blobe7c8ad463806dbd8deaff6d557f71bf85cb984ff
1 #include "InheritedOpC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 int
33 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
35 CORBA::ORB_var orb;
36 Outer::Derived_var target;
38 try
40 orb = CORBA::ORB_init (argc, argv);
42 if (parse_args (argc, argv) != 0)
43 return 1;
45 CORBA::Object_var tmp = orb->string_to_object (ior);
47 target = Outer::Derived::_narrow (tmp.in ());
49 if (CORBA::is_nil (target.in ()))
51 ACE_ERROR_RETURN ((LM_DEBUG,
52 ACE_TEXT ("Nil Outer::Derived ")
53 ACE_TEXT ("reference <%s>\n"),
54 ior),
55 1);
58 target->BaseOp ();
59 target->shutdown ();
61 orb->destroy ();
63 catch (const CORBA::BAD_OPERATION&)
65 ACE_ERROR ((LM_ERROR,
66 ACE_TEXT ("client - target operation ")
67 ACE_TEXT ("BaseOp returned BAD_OPERATION\n")));
68 target->shutdown ();
69 orb->destroy ();
70 return 1;
72 catch (const CORBA::Exception& ex)
74 ex._tao_print_exception ("client - Exception caught:");
75 target->shutdown ();
76 orb->destroy ();
77 return 1;
80 return 0;