Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / RTCORBA / Persistent_IOR / client.cpp
blob016bb479251de74f4540c5d849769b9290cbfe1f
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
4 static int iterations = 5;
5 static int shutdown_server = 0;
7 static const ACE_TCHAR *ior = 0;
9 static int
10 parse_args (int argc, ACE_TCHAR **argv)
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:x"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'k':
19 ior = get_opts.opt_arg ();
20 break;
22 case 'i':
23 iterations = ACE_OS::atoi (get_opts.opt_arg ());
24 break;
26 case 'x':
27 shutdown_server = 1;
28 break;
30 case '?':
31 default:
32 ACE_ERROR_RETURN ((LM_ERROR,
33 "usage: %s "
34 "-k ior "
35 "-i iterations "
36 "-x shutdown server "
37 "\n",
38 argv [0]),
39 -1);
42 if (ior == 0)
43 ACE_ERROR_RETURN ((LM_ERROR,
44 "Error: No IOR specified\n"),
45 -1);
47 return 0;
50 int
51 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
53 try
55 CORBA::ORB_var orb =
56 CORBA::ORB_init (argc, argv);
58 int result =
59 parse_args (argc, argv);
60 if (result != 0)
61 return result;
63 CORBA::Object_var object =
64 orb->string_to_object (ior);
66 test_var test =
67 test::_narrow (object.in ());
69 if (CORBA::is_nil (test.in ()))
71 ACE_ERROR_RETURN ((LM_DEBUG,
72 "Nil reference <%s>\n",
73 ior),
74 1);
77 for (int i = 0; i < iterations; i++)
79 test->method ();
82 if (shutdown_server)
84 test->shutdown ();
87 orb->destroy ();
89 catch (const CORBA::Exception& ex)
91 ex._tao_print_exception ("Unexpected exception!");
92 return -1;
95 return 0;