3 #include "TestAppExceptionC.h"
4 #include "Foo_A_ClientEngine.h"
5 #include "ace/Get_Opt.h"
9 : TestAppBase("TP_Test_2_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();
40 ClientApp::init(int argc
, ACE_TCHAR
* argv
[])
42 this->orb_
= CORBA::ORB_init(argc
, argv
);
44 // Parse the command-line args for this application.
45 // * Raises -1 if problems are encountered.
46 // * Returns 1 if the usage statement was explicitly requested.
47 // * Returns 0 otherwise.
48 return this->parse_args(argc
, argv
);
53 ClientApp::client_setup()
55 // Turn the ior_ into a Foo_A obj ref.
56 Foo_A_var foo
= RefHelper
<Foo_A
>::string_to_ref(this->orb_
.in(),
59 // Create the ClientEngine object, and give it the Foo_A obj ref.
60 this->engine_
= new Foo_A_ClientEngine(foo
.in(), this->client_id_
);
65 ClientApp::run_engine()
67 bool result
= this->engine_
->execute();
68 return result
? 0 : -1;
79 ClientApp::parse_args(int argc
, ACE_TCHAR
* argv
[])
81 this->exe_name_
= argv
[0];
83 ACE_Get_Opt
get_opts(argc
, argv
, ACE_TEXT("i:k:n:"));
87 while ((c
= get_opts()) != -1)
93 this->ior_
= get_opts
.opt_arg();
97 result
= set_arg(this->client_kind_
,
104 result
= set_arg(this->client_id_
,
111 this->usage_statement();
115 this->usage_statement();
125 return this->arg_dependency_checks();
129 ClientApp::usage_statement()
132 "Usage: %s [options]\n\n"
135 "\t[-k <client_kind>]\n"
136 "\t[-n <client_id>]\n"
138 this->exe_name_
.c_str()));
143 ClientApp::arg_dependency_checks()
145 if (this->ior_
== ACE_TEXT("Not Set"))
148 "Error: Missing required command-line option (-i <ior>).\n"));
149 this->usage_statement();
153 if (this->client_id_
<= 0)
156 "Error: Invalid command-line option (-n <client id>).\n"
157 " The client id should be positive integer.\n"));
158 this->usage_statement();
167 ClientApp::set_arg(unsigned& value
,
168 const ACE_TCHAR
* arg
,
173 int tmp
= ACE_OS::atoi(arg
);
178 "Error: -%c <%s> must be integer type with a value of, "
179 "at least, %d.\n", opt
, name
, min
));
180 this->usage_statement();