Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / interop-tests / CdrOutArg / orbix / server.cxx
blob7a65feca508a3c1ed259087bc12c980dc9e6acec
1 #include <stdio.h>
2 #include <iostream>
3 #include <omg/PortableServer.hh>
4 #include "test_i.h"
5 #include "Server_ORBInitializer.h"
7 const char* ior_output_file = "test.ior";
9 //FUZZ: disable check_for_improper_main_declaration
10 int
11 main(int argc, char* argv[])
13 try
15 PortableInterceptor::ORBInitializer_var initializer = new Server_ORBInitializer();
17 PortableInterceptor::register_orb_initializer (initializer.in ());
19 // Now we can create the ORB
20 CORBA::ORB_var orb =
21 CORBA::ORB_init (argc, argv, "taodemo");
23 CORBA::Object_var poa_object =
24 orb->resolve_initial_references ("RootPOA");
26 assert(!CORBA::is_nil (poa_object.in ()));
28 PortableServer::POA_var root_poa =
29 PortableServer::POA::_narrow (poa_object.in ());
31 PortableServer::POAManager_var poa_manager =
32 root_poa->the_POAManager ();
34 poa_manager->activate ();
36 CDR_Out_Arg_i server_impl(orb.in ());
38 PortableServer::ObjectId_var id =
39 root_poa->activate_object (&server_impl);
41 CORBA::Object_var test_obj =
42 root_poa->id_to_reference (id.in ());
44 Interop::CDR_Out_Arg_var server =
45 Interop::CDR_Out_Arg::_narrow (test_obj.in ());
47 CORBA::String_var ior =
48 orb->object_to_string (server.in ());
50 printf("Interop::CDR_Out_Arg: <%s>\n",
51 ior.in ());
53 // If the ior_output_file exists, output the ior to it
54 if (ior_output_file != 0)
56 FILE *output_file= fopen (ior_output_file, "w");
57 if (output_file == 0) {
58 printf("Cannot open output file for writing IOR: %s\n",
59 ior_output_file);
60 return 1;
62 fprintf (output_file, "%s", ior.in ());
63 fclose (output_file);
66 orb->run ();
68 printf("event loop finished\n");
70 root_poa->destroy (true, true);
72 orb->destroy ();
74 catch (const CORBA::Exception& ex)
76 std::cerr << "Caught exception in server:" << ex << std::endl;
77 return 1;
80 return 0;