Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / NestedUpcall / Simple / client.cpp
blob1f251ce35214944dc3d9d370506aee115d524a83
1 #include "client_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Task.h"
5 static const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
6 // Server IOR.
8 static int shutdown_server = 0;
9 // Flag to tell server to shutdown.
11 static CORBA::UShort call_count = 5;
12 // # of nested calls to be made.
14 static int quiet = 0;
15 // The test is quiet...
17 class Client_Task
19 public:
20 Client_Task (client_ptr c,
21 server_ptr s);
22 int svc ();
24 private:
25 client_var client_;
26 server_var server_;
29 Client_Task::Client_Task (client_ptr c,
30 server_ptr s)
31 : client_ (client::_duplicate (c)),
32 server_ (server::_duplicate (s))
36 int
37 Client_Task::svc ()
39 try
41 if (!quiet)
42 ACE_DEBUG ((LM_DEBUG,
43 "(%t) Client_Task::svc calling start -> time to live = %d\n",
44 call_count));
46 // Now, we can invoke an operation on the remote side.
47 this->server_->start (this->client_.in (),
48 call_count);
50 catch (const CORBA::Exception& ex)
52 ex._tao_print_exception ("Client_Task::svc");
53 return -1;
55 return 0;
58 static int
59 parse_args (int argc,
60 ACE_TCHAR **argv)
62 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("qxn:k:"));
63 int c;
65 while ((c = get_opts ()) != -1)
66 switch (c)
68 case 'q':
69 quiet = 1;
70 break;
72 case 'x':
73 shutdown_server = 1;
74 break;
76 case 'n':
77 call_count = ACE_OS::atoi (get_opts.opt_arg ());
78 break;
80 case 'k':
81 ior = get_opts.opt_arg ();
82 break;
84 case '?':
85 default:
86 ACE_ERROR_RETURN ((LM_ERROR,
87 "usage: %s"
88 " [-n number of nested calls]"
89 " [-k ior]"
90 " [-q (quite)]"
91 " [-x (shutdown server)]"
92 "\n",
93 argv[0]),
94 -1);
97 if (ior == 0)
98 ACE_ERROR_RETURN ((LM_ERROR,
99 "%s: no nested up calls server ior specified\n",
100 argv[0]),
101 -1);
103 // Indicates successful parsing of command line.
104 return 0;
108 ACE_TMAIN (int argc,
109 ACE_TCHAR **argv)
113 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
115 int result = parse_args (argc, argv);
116 if (result != 0)
117 return result;
119 CORBA::Object_var object = orb->resolve_initial_references ("RootPOA");
121 PortableServer::POA_var root_poa =
122 PortableServer::POA::_narrow (object.in ());
124 PortableServer::POAManager_var poa_manager =
125 root_poa->the_POAManager ();
127 poa_manager->activate ();
129 object = orb->string_to_object (ior);
131 server_var server = server::_narrow (object.in ());
133 // Create an client object to hand to the other side...
134 client_i client_servant (quiet,
135 server.in ());
137 PortableServer::ObjectId_var id =
138 root_poa->activate_object (&client_servant);
140 CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
142 client_var client_object = client::_narrow (object_act.in ());
144 Client_Task client_tasks (client_object.in (),
145 server.in ());
147 client_tasks.svc ();
149 if (shutdown_server)
151 server->shutdown ();
154 root_poa->destroy (true, true);
156 catch (const CORBA::Exception& ex)
158 ex._tao_print_exception ("client::main");
159 return -1;
161 return 0;