3 #include "TestAppExceptionC.h"
4 #include "Foo_C_ClientEngine.h"
5 #include "ace/Get_Opt.h"
9 : TestAppBase("TP_Test_4_Client"),
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();
42 ClientApp::init(int argc
, ACE_TCHAR
* argv
[])
44 this->orb_
= CORBA::ORB_init(argc
, argv
);
46 // Parse the command-line args for this application.
47 // * Raises -1 if problems are encountered.
48 // * Returns 1 if the usage statement was explicitly requested.
49 // * Returns 0 otherwise.
50 return this->parse_args(argc
, argv
);
55 ClientApp::client_setup()
57 // Turn the ior_ into a Foo_C obj ref.
58 Foo_C_var foo
= RefHelper
<Foo_C
>::string_to_ref(this->orb_
.in(),
61 // Create the ClientEngine object, and give it the Foo_C obj ref.
62 this->engine_
= new Foo_C_ClientEngine(foo
.in(), this->client_id_
);
67 ClientApp::run_engine()
69 bool result
= this->engine_
->execute();
71 return result
? 0 : -1;
82 ClientApp::parse_args(int argc
, ACE_TCHAR
* argv
[])
84 this->exe_name_
= argv
[0];
86 ACE_Get_Opt
get_opts(argc
, argv
, ACE_TEXT("i:k:n:"));
90 while ((c
= get_opts()) != -1)
96 this->ior_
= get_opts
.opt_arg();
100 result
= set_arg(this->client_kind_
,
107 result
= set_arg(this->client_id_
,
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[-k <client_kind>]\n"
139 "\t[-n <client_id>]\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: Invalid 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();