1 #include "Progress_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "tao/FlResource/FlResource_Loader.h"
7 #include <FL/Fl_Window.H>
9 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("progress.ior");
10 int n_iterations
= 1000;
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:p:i:"));
19 while ((c
= get_opts ()) != -1)
23 ior_output_file
= get_opts
.opt_arg ();
27 n_peers
= ACE_OS::atoi (get_opts
.opt_arg ());
31 n_iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
36 ACE_ERROR_RETURN ((LM_ERROR
,
45 // Indicates successful parsing of the command line
50 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
52 TAO::FlResource_Loader fl_loader
;
56 CORBA::ORB_init (argc
, argv
);
58 if (parse_args (argc
, argv
) != 0)
62 int h
= 30 * n_peers
+ 20;
63 Fl_Window
window(w
, h
);
65 Progress_Window
sw (n_peers
, n_iterations
,
70 window
.resizable (&sw
);
74 char* targv
[] = { ACE_TEXT_ALWAYS_CHAR (argv
[0]) };
75 window
.show (1, targv
);
79 CORBA::Object_var poa_object
=
80 orb
->resolve_initial_references("RootPOA");
82 if (CORBA::is_nil (poa_object
.in ()))
83 ACE_ERROR_RETURN ((LM_ERROR
,
84 " (%P|%t) Unable to initialize the POA.\n"),
87 PortableServer::POA_var root_poa
=
88 PortableServer::POA::_narrow (poa_object
.in ());
90 PortableServer::POAManager_var poa_manager
=
91 root_poa
->the_POAManager ();
93 poa_manager
->activate ();
95 Progress_i
server_impl (&sw
);
100 CORBA::String_var ior
=
101 orb
->object_to_string (server
.in ());
103 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
105 // If the ior_output_file exists, output the ior to it
106 if (ior_output_file
!= 0)
108 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
109 if (output_file
== 0)
110 ACE_ERROR_RETURN ((LM_ERROR
,
111 "Cannot open output file for writing IOR: %s",
114 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
115 ACE_OS::fclose (output_file
);
118 if (Fl::run () == -1)
119 ACE_ERROR_RETURN ((LM_ERROR
, "%p\n", "Fl::run"), -1);
120 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
122 catch (const CORBA::Exception
& ex
)
124 ex
._tao_print_exception ("Caught exception:");