Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / COIOP / COIOP_Test.cpp
blob0facd82fbec64c698437a06edf4f5c4ee5ae0b06
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"
7 #include "tao/Strategies/advanced_resource.h"
9 const ACE_TCHAR *output = ACE_TEXT("test.ior");
10 const ACE_TCHAR *input = ACE_TEXT("file://test.ior");
11 ACE_CString server_orb;
12 ACE_CString client_orb;
13 CORBA::Boolean result = false;
15 int
16 parse_args (int argc, ACE_TCHAR *argv[])
18 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("sk:o:n"));
19 int c;
21 while ((c = get_opts ()) != -1)
22 switch (c)
24 case 's' :
25 result = true;
26 break;
27 case 'o':
28 output = get_opts.opt_arg ();
29 break;
30 case 'k':
31 input = get_opts.opt_arg ();
32 break;
33 case 'n':
34 server_orb.set ("server_orb");
35 client_orb.set ("client_orb");
36 break;
37 case '?':
38 default:
39 // This is a hack but that is okay!
40 return 0;
42 // Indicates successful parsing of the command line
43 return 0;
46 int
47 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
49 if (parse_args (argc,
50 argv) == -1)
51 return -1;
53 try
55 ACE_Argv_Type_Converter satc (argc, argv);
56 CORBA::ORB_var sorb =
57 CORBA::ORB_init (satc.get_argc (),
58 satc.get_TCHAR_argv (),
59 server_orb.c_str ());
61 ACE_Manual_Event me;
62 Server_Task server_task (output,
63 sorb.in (),
64 me,
65 ACE_Thread_Manager::instance ());
67 if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
69 1) == -1)
71 ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
74 // Wait for the server thread to do some processing
75 me.wait ();
77 ACE_Argv_Type_Converter catc (argc, argv);
78 CORBA::ORB_var corb =
79 CORBA::ORB_init (catc.get_argc (),
80 catc.get_TCHAR_argv (),
81 client_orb.c_str ());
83 Client_Task client_task (input,
84 corb.in (),
85 ACE_Thread_Manager::instance (),
86 result);
88 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
90 1) == -1)
92 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
95 // Wait for the client and server to finish
96 ACE_Thread_Manager::instance ()->wait ();
98 // Now that all threads have completed we can destroy the ORB
99 sorb->destroy ();
100 if (server_orb != client_orb)
102 corb->destroy ();
105 catch (const CORBA::Exception&)
107 // Ignore exceptions..
109 return 0;