Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool2 / ClientApp.cpp
blobef25dc055cbf89e3968164eba05c36d29d7b57e7
1 #include "ClientApp.h"
2 #include "FooC.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Log_Msg.h"
7 ClientApp::ClientApp()
12 ClientApp::~ClientApp()
17 int
18 ClientApp::run(int argc, ACE_TCHAR* argv[])
20 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
22 // Parse the command-line args for this application.
23 // * Raises -1 if problems are encountered.
24 // * Returns 1 if the usage statement was explicitly requested.
25 // * Returns 0 otherwise.
26 int const result = this->parse_args(argc, argv);
27 if (result != 0)
29 return result;
32 CORBA::Object_var obj
33 = orb->string_to_object(this->ior_.c_str());
35 if (CORBA::is_nil(obj.in()))
37 ACE_ERROR((LM_ERROR,
38 "(%P|%t) Failed to convert IOR string to obj ref.\n"));
39 throw TestException();
42 Foo_var foo = Foo::_narrow(obj.in());
44 if (CORBA::is_nil(foo.in()))
46 ACE_ERROR((LM_ERROR,
47 "(%P|%t) Failed to narrow obj ref to Foo interface.\n"));
48 throw TestException();
51 for (CORBA::Long i = 1; i <= 100; i++)
53 foo->op1();
54 foo->op2(i);
55 CORBA::Long value = foo->op3();
57 ACE_DEBUG((LM_DEBUG,
58 "(%P|%t) ===> Value retrieved from op3() == %d\n",
59 value));
61 for (CORBA::Long j = 1; j <= 5; j++)
63 foo->op4(495 + (i * 5) + j);
66 try
68 foo->op5();
70 catch (const FooException& )
72 ACE_DEBUG((LM_DEBUG,
73 "(%P|%t) ===> Caught FooException - as expected.\n"));
77 ACE_DEBUG((LM_DEBUG,
78 "(%P|%t) ===> Tell server that we are done().\n"));
80 foo->done();
82 ACE_DEBUG((LM_DEBUG,
83 "(%P|%t) ===> Back from done().\n"));
85 return 0;
89 int
90 ClientApp::parse_args(int argc, ACE_TCHAR* argv[])
92 this->exe_name_ = argv[0];
94 ACE_Get_Opt get_opts(argc, argv, ACE_TEXT("i:"));
96 int c;
98 while ((c = get_opts()) != -1)
100 switch (c)
102 case 'i':
103 this->ior_ = get_opts.opt_arg();
104 break;
106 case '?':
107 this->usage_statement();
108 return 1;
109 default:
110 this->usage_statement();
111 return -1;
115 return 0;
119 void
120 ClientApp::usage_statement()
122 ACE_ERROR((LM_ERROR,
123 "Usage: %s [options]\n\n"
124 "OPTIONS:\n\n"
125 "\t[-i <ior>]\n"
126 "\t[-?]\n\n",
127 this->exe_name_.c_str()));