2 #include "TestInf/AppHelper.h"
3 #include "TestInf/TestAppExceptionC.h"
4 #include "TestServant/Foo_ClientEngine.h"
5 #include "ace/Get_Opt.h"
9 : TestAppBase("CSD_PT_ClientApp"),
10 ior_(ACE_TEXT("Not Set")),
17 ClientApp::~ClientApp()
23 ClientApp::run_i(int argc
, ACE_TCHAR
* argv
[])
25 int result
= this->init(argc
, argv
);
33 result
= this->run_engine();
41 ClientApp::init(int argc
, ACE_TCHAR
* argv
[])
43 this->orb_
= CORBA::ORB_init(argc
, argv
);
45 // Parse the command-line args for this application.
46 // * Returns -1 if problems are encountered.
47 // * Returns 1 if the usage statement was explicitly requested.
48 // * Returns 0 otherwise.
49 return this->parse_args(argc
, argv
);
54 ClientApp::client_setup()
56 // Turn the ior_ into a Foo obj ref.
57 Foo_var foo
= RefHelper
<Foo
>::string_to_ref(this->orb_
.in(),
60 // Create the ClientEngine object, and give it the Foo obj ref.
61 this->engine_
= new Foo_ClientEngine(foo
.in(), this->client_id_
);
66 ClientApp::run_engine()
68 bool result
= this->engine_
->execute(this->num_loops_
);
69 return result
? 0 : -1;
80 ClientApp::parse_args(int argc
, ACE_TCHAR
* argv
[])
82 this->exe_name_
= argv
[0];
84 ACE_Get_Opt
get_opts(argc
, argv
, ACE_TEXT("i:n:l:"));
88 while ((c
= get_opts()) != -1)
94 this->ior_
= get_opts
.opt_arg();
98 result
= this->set_arg(this->client_id_
,
106 result
= this->set_arg(this->num_loops_
,
114 this->usage_statement();
118 this->usage_statement();
128 return this->arg_dependency_checks();
132 ClientApp::usage_statement()
135 "Usage: %s [options]\n\n"
138 "\t[-n <client_id>]\n"
139 "\t[-l <num_loops>]\n"
141 this->exe_name_
.c_str()));
146 ClientApp::arg_dependency_checks()
148 if (this->ior_
== ACE_TEXT("Not Set"))
151 "Error: Missing required command-line option (-i <ior>).\n"));
152 this->usage_statement();
156 if (this->client_id_
<= 0)
159 "Error: Required command-line option (-n <client id>).\n"
160 " The client id should be positive integer.\n"));
161 this->usage_statement();
170 ClientApp::set_arg(unsigned& value
,
171 const ACE_TCHAR
* arg
,
176 int tmp
= ACE_OS::atoi(arg
);
181 "Error: -%c <%s> must be integer type with a value of, "
182 "at least, %d.\n", opt
, name
, min
));
183 this->usage_statement();