2 #include "ace/Get_Opt.h"
3 #include "tao/FlResource/FlResource_Loader.h"
7 const ACE_TCHAR
*ior_output_file
= 0;
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
15 while ((c
= get_opts ()) != -1)
19 ior_output_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 Fl_Window
window(300, 300);
39 TAO::FlResource_Loader fl_loader
;
41 Simple_Window
sw (10, 10,
42 window
.w () - 20, window
.h () - 20);
43 window
.resizable (&sw
);
50 CORBA::ORB_init (argc
, argv
);
52 if (parse_args (argc
, argv
) != 0)
55 char* targv
[] = { ACE_TEXT_ALWAYS_CHAR (argv
[0]) };
56 window
.show (1, targv
);
60 CORBA::Object_var poa_object
=
61 orb
->resolve_initial_references("RootPOA");
63 if (CORBA::is_nil (poa_object
.in ()))
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 " (%P|%t) Unable to initialize the POA.\n"),
68 PortableServer::POA_var root_poa
=
69 PortableServer::POA::_narrow (poa_object
.in ());
71 PortableServer::POAManager_var poa_manager
=
72 root_poa
->the_POAManager ();
74 Simple_Server_i
server_impl (orb
.in (), &sw
);
76 PortableServer::ObjectId_var id
=
77 root_poa
->activate_object (&server_impl
);
79 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
81 Simple_Server_var server
=
82 Simple_Server::_narrow (object
.in ());
84 CORBA::String_var ior
=
85 orb
->object_to_string (server
.in ());
87 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
89 // If the ior_output_file exists, output the ior to it
90 if (ior_output_file
!= 0)
92 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "Cannot open output file for writing IOR: %s",
98 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
99 ACE_OS::fclose (output_file
);
102 poa_manager
->activate ();
104 if (Fl::run () == -1)
105 ACE_ERROR_RETURN ((LM_ERROR
, "%p\n", "Fl::run"), -1);
106 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
108 catch (const CORBA::Exception
& ex
)
110 ex
._tao_print_exception ("Caught exception:");