2 #include "ace/Get_Opt.h"
8 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
11 Widget toplevel
= XtAppInitialize (&app
,
21 TAO::XtResource_Loader
xt_loader (app
);
23 Control
control (toplevel
);
29 CORBA::ORB_init (argc
, argv
);
31 Client
client (orb
.in ());
33 client
.parse_args (argc
, argv
);
35 client
.add_callback (control
);
39 XtRealizeWidget (toplevel
);
42 catch (const CORBA::Exception
& ex
)
44 ex
._tao_print_exception ("Caught exception:");
50 Client::Client (CORBA::ORB_ptr orb
)
51 : orb_ (CORBA::ORB::_duplicate (orb
))
60 Client::parse_args (int argc
,
63 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
65 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
68 while ((c
= get_opts ()) != -1)
72 ior
= get_opts
.opt_arg ();
83 CORBA::Object_var object
=
84 this->orb_
->string_to_object (ior
);
87 Stopwatch::_narrow (object
.in ());
89 if (CORBA::is_nil(this->server_
.in ()))
92 "\n The server value is nil "));
97 Client::add_callback (Control
&ctrl
)
99 XtPointer client_data
= static_cast<XtPointer
> (this);
101 // Register callbacks, specifying the object's instance pointer as
103 XtAddCallback (ctrl
.startwidget (),
105 &Client::start_callback
,
108 XtAddCallback (ctrl
.stopwidget (),
110 &Client::stop_callback
,
115 Client::start_callback (Widget
/*widget*/,
116 XtPointer client_data
,
119 Client
*self
= static_cast<Client
*> (client_data
);
124 Client::stop_callback (Widget
/*widget*/,
125 XtPointer client_data
,
128 Client
*self
= static_cast<Client
*> (client_data
);
133 Client::start_hook ()
137 this->server_
->start ();
139 catch (const CORBA::Exception
& ex
)
141 ex
._tao_print_exception (
142 "Caught an exception in the start button callback");
152 this->server_
->stop ();
154 catch (const CORBA::Exception
& ex
)
156 ex
._tao_print_exception (
157 "Caught an exception in the stop button callback");