1 #include "Server_Task.h"
2 #include "Client_Task.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Argv_Type_Converter.h"
5 #include "ace/SString.h"
6 #include "ace/Manual_Event.h"
8 const ACE_TCHAR
*output
= ACE_TEXT("test.ior");
9 const ACE_TCHAR
*input
= ACE_TEXT("file://test.ior");
10 const ACE_TCHAR
*mode
= ACE_TEXT("SYNC_NONE");
12 Client_Task::ClientSyncModeEnum syncMode
= Client_Task::MODE_NONE
;
14 // static int named_orbs = 0;
15 ACE_CString server_orb
;
16 ACE_CString client_orb
;
18 parse_args (int argc
, ACE_TCHAR
*argv
[])
20 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:o:n:m:"));
23 while ((c
= get_opts ()) != -1)
27 output
= get_opts
.opt_arg ();
30 input
= get_opts
.opt_arg ();
34 server_orb
.set ("server_orb");
35 client_orb
.set ("client_orb");
38 mode
= get_opts
.opt_arg ();
39 // cout << "mode = " << mode << endl;
40 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) - mode set to <%C> for collocated oneway test\n", mode
));
42 if(!ACE_OS::strcmp(ACE_TEXT("none"), mode
)) {
43 syncMode
= Client_Task::MODE_NONE
;
45 else if (!ACE_OS::strcmp(ACE_TEXT("transport"), mode
)) {
46 syncMode
= Client_Task::MODE_TRANSPORT
;
48 else if (!ACE_OS::strcmp(ACE_TEXT("server"), mode
)) {
49 syncMode
= Client_Task::MODE_SERVER
;
51 else if (!ACE_OS::strcmp(ACE_TEXT("target"), mode
)) {
52 syncMode
= Client_Task::MODE_TARGET
;
56 // same hack used in original test!
62 // This is a hack but that is okay!
65 // Indicates successful parsing of the command line
70 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
78 ACE_Argv_Type_Converter
satc (argc
, argv
);
80 CORBA::ORB_init (satc
.get_argc (),
81 satc
.get_TCHAR_argv (),
85 Server_Task
server_task (output
,
88 ACE_Thread_Manager::instance ());
90 if (server_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
94 ACE_ERROR ((LM_ERROR
, "Error activating server task\n"));
97 // Wait for the server thread to do some processing
100 ACE_Argv_Type_Converter
catc (argc
, argv
);
101 CORBA::ORB_var corb
=
102 CORBA::ORB_init (catc
.get_argc (),
103 catc
.get_TCHAR_argv (),
104 client_orb
.c_str ());
106 Client_Task
client_task (input
,
109 ACE_Thread_Manager::instance ());
111 if (client_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
115 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
118 ACE_Thread_Manager::instance ()->wait ();
120 catch (const CORBA::Exception
&)
122 // Ignore exceptions..