1 #include "Grid_Client_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Read_Buffer.h"
5 // This is the interface program that accesses the remote object
8 Grid_Client_i::Grid_Client_i ()
20 Grid_Client_i::~Grid_Client_i ()
26 Grid_Client_i::parse_args (int argc
,
29 // Parses some of the options that are specific to this example
30 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("df:nk:xw:h:v:"));
33 while ((c
= get_opts ()) != -1)
37 this->width_
= (u_int
) ACE_OS::atoi (get_opts
.opt_arg ());
40 this->height_
= (u_int
) ACE_OS::atoi (get_opts
.opt_arg ());
43 this->value_
= (u_int
) ACE_OS::atoi (get_opts
.opt_arg ());
48 width_
= Grid::DEFAULT_SIZE
;
50 height_
= Grid::DEFAULT_SIZE
;
52 value_
= Grid::DEFAULT_VALUE
;
57 Grid_Client_i::run (const char *name
,
61 // Initialize the client.
62 if (client
.init (name
, argc
, argv
) == -1)
65 if (this->parse_args (argc
, argv
) == -1)
73 Grid_ptr grid
= client
->make_grid (width_
,
77 "(%P|%t) Made the grid successfully\n"));
79 for (CORBA::Short index_
= 0; index_
< width_
; index_
++)
81 for (CORBA::Short ctr
= 0; ctr
< height_
; ctr
++)
84 "Grid value [%d][%d] = %d\n",index_
, ctr
,value_
+ctr
));
85 // Set a value on the grid
93 "(%P|%t) Setting a value for the grid\n"));
96 if (client
.shutdown () == 1) {
101 catch (const CORBA::UserException
& range_ex
)
103 range_ex
._tao_print_exception ("\tFrom get and set grid");
106 catch (const CORBA::SystemException
& memex
)
108 memex
._tao_print_exception ("Cannot make grid as Memory exhausted");