blob: f7d3362010cee5b601c8a50a6a71b42a5b0329c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#include "ClientApp.h"
#include "Foo_A_ClientEngine.h"
#include "AppHelper.h"
#include "TestAppExceptionC.h"
#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"
ClientApp::ClientApp()
: TestAppBase("TP_Test_1_Client")
{
}
ClientApp::~ClientApp()
{
}
int
ClientApp::run_i(int argc, ACE_TCHAR* argv[])
{
// Initialize the ORB before parsing our own args.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Parse the command-line args for this application.
// * Returns -1 if problems are encountered.
// * Returns 1 if the usage statement was explicitly requested.
// * Returns 0 otherwise.
int result = this->parse_args(argc, argv);
if (result != 0)
{
return result;
}
// Convert the IOR string to a Foo_A object reference.
Foo_A_var foo = RefHelper<Foo_A>::string_to_ref(orb.in(),
this->ior_.c_str());
// Create the appropriate client "engine" object.
Foo_A_ClientEngine engine(foo.in());
// Execute the client algorithm
result = engine.execute() ? 0 : -1;
return result;
}
int
ClientApp::parse_args(int argc, ACE_TCHAR* argv[])
{
ACE_Get_Opt get_opts(argc, argv, ACE_TEXT("i:"));
int c;
while ((c = get_opts()) != -1)
{
switch (c)
{
case 'i':
this->ior_ = get_opts.opt_arg();
break;
case '?':
ACE_DEBUG((LM_DEBUG,
"(%P|%t) usage: %s -i <ior_string>\n",
argv[0]));
return 1;
default:
ACE_ERROR((LM_ERROR,
"(%P|%t) usage: %s -i <ior_string>\n",
argv[0]));
return -1;
}
}
return 0;
}
|