Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / CSD_Strategy_Tests / TP_Test_1 / ClientApp.cpp
blobf7d3362010cee5b601c8a50a6a71b42a5b0329c8
1 #include "ClientApp.h"
2 #include "Foo_A_ClientEngine.h"
3 #include "AppHelper.h"
4 #include "TestAppExceptionC.h"
5 #include "ace/Get_Opt.h"
6 #include "ace/Log_Msg.h"
9 ClientApp::ClientApp()
10 : TestAppBase("TP_Test_1_Client")
15 ClientApp::~ClientApp()
20 int
21 ClientApp::run_i(int argc, ACE_TCHAR* argv[])
23 // Initialize the ORB before parsing our own args.
24 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
26 // Parse the command-line args for this application.
27 // * Returns -1 if problems are encountered.
28 // * Returns 1 if the usage statement was explicitly requested.
29 // * Returns 0 otherwise.
30 int result = this->parse_args(argc, argv);
31 if (result != 0)
33 return result;
35 // Convert the IOR string to a Foo_A object reference.
36 Foo_A_var foo = RefHelper<Foo_A>::string_to_ref(orb.in(),
37 this->ior_.c_str());
39 // Create the appropriate client "engine" object.
40 Foo_A_ClientEngine engine(foo.in());
42 // Execute the client algorithm
43 result = engine.execute() ? 0 : -1;
45 return result;
49 int
50 ClientApp::parse_args(int argc, ACE_TCHAR* argv[])
52 ACE_Get_Opt get_opts(argc, argv, ACE_TEXT("i:"));
54 int c;
56 while ((c = get_opts()) != -1)
58 switch (c)
60 case 'i':
61 this->ior_ = get_opts.opt_arg();
62 break;
64 case '?':
65 ACE_DEBUG((LM_DEBUG,
66 "(%P|%t) usage: %s -i <ior_string>\n",
67 argv[0]));
68 return 1;
70 default:
71 ACE_ERROR((LM_ERROR,
72 "(%P|%t) usage: %s -i <ior_string>\n",
73 argv[0]));
74 return -1;
78 return 0;