2 //=============================================================================
6 * The classe define the templates for the client and server.
8 * @author Balachandran Natarajan <bala@cs.wustl.edu>
10 //=============================================================================
16 #include "tao/Utils/ORB_Manager.h"
17 #include "orbsvcs/Naming/Naming_Client.h"
18 #include "ace/Get_Opt.h"
19 #include "ace/Read_Buffer.h"
20 #include "tao/Intrusive_Ref_Count_Handle_T.h"
25 * @brief A set of useful class Templates for using the TAO CORBA
28 * A template server definition. This template can be used by
29 * single server/client projects for definition of their
30 * server/clients. See the directories time, bank, echo for
31 * further details of implementation.
33 template <class Servant
>
43 /// Initialize the Server state - parsing arguments and waiting.
44 /// interface_name is the name used to register the Servant.
45 int init (const char *servant_name
,
49 /// After calling <init>, this method will register the server with
50 /// the TAO Naming Service using the name passed to this method.
51 int register_name (const char *name
);
56 /// Ignore this method if you are not testing the InterOperable
58 int test_for_ins (const char *ior
);
61 /// Parses the commandline arguments.
64 /// A holder of the servant that does ref counting for him.
65 typedef TAO_Intrusive_Ref_Count_Handle
<Servant
> Servant_var
;
68 /// The ORB manager - a helper class for accessing the POA and
69 /// registering objects.
70 TAO_ORB_Manager orb_manager_
;
72 /// helper class for getting access to Naming Service.
73 TAO_Naming_Client naming_client_
;
75 /// File where the IOR of the server object is stored.
76 ACE_TCHAR
*ior_output_file_
;
78 /// Flag to indicate whether naming service could be used
81 /// Used test the INS.
84 /// Number of command line arguments.
87 /// The command line arguments.
94 * @brief Template Client class
96 * A template client implementation for a single server/client
97 * model. The example usage of these usage can be found in the
98 * sub-directories below
100 template <class ServerInterface
>
110 /// Initialize the client communication endpoint with server.
111 int init (const char *name
, int argc
, ACE_TCHAR
*argv
[]);
113 /// Return the interface object pointer.
114 ServerInterface
*operator-> () { return server_
.in (); }
116 /// Returns the shutdown flag.
119 /// Fills in the shutdwon flag.
120 void do_shutdown (int);
122 /// Initialize naming service
123 int obtain_initial_references (const char *name
);
125 CORBA::ORB_ptr
orb ()
127 return CORBA::ORB::_duplicate (this->orb_
.in ());
131 /// Function to read the server IOR from a file.
132 int read_ior (ACE_TCHAR
*filename
);
134 /// Parses the arguments passed on the command line.
137 /// Remember our orb.
140 /// helper class for getting access to Naming Service.
141 TAO_Naming_Client naming_client_
;
143 /// # of arguments on the command line.
146 /// arguments from command line.
147 ACE_TCHAR
**argv_
{};
149 /// IOR of the obj ref of the server.
153 typedef TAO_Intrusive_Ref_Count_Handle
<ServerInterface
> ServerInterface_var
;
154 ServerInterface_var server_
;
156 /// Flag to use the naming service
159 /// Flag for shutting down the server
163 #include "Simple_util.cpp"
165 #endif /* TAO_UTIL_H */