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 "ace/Get_Opt.h"
18 #include "ace/Read_Buffer.h"
19 #include "tao/Intrusive_Ref_Count_Handle_T.h"
24 * @brief A set of useful class Templates for using the TAO CORBA
27 * A template server definition. This template can be used by
28 * single server/client projects for definition of their
29 * server/clients. See the directories time, bank, echo for
30 * further details of implementation.
32 template <class Servant
>
42 /// Initialize the Server state - parsing arguments and waiting.
43 /// interface_name is the name used to register the Servant.
44 int init (const char *servant_name
,
51 /// Ignore this method if you are not testing the InterOperable
53 int test_for_ins (const char *ior
);
56 /// Parses the commandline arguments.
59 /// A holder of the servant that does ref counting for him.
60 typedef TAO_Intrusive_Ref_Count_Handle
<Servant
> Servant_var
;
63 /// The ORB manager - a helper class for accessing the POA and
64 /// registering objects.
65 TAO_ORB_Manager orb_manager_
;
67 /// File where the IOR of the server object is stored.
68 ACE_TCHAR
*ior_output_file_
;
70 /// Flag to indicate whether naming service could be used
73 /// Used test the INS.
76 /// Number of command line arguments.
79 /// The command line arguments.
86 * @brief Template Client class
88 * A template client implementation for a single server/client
89 * model. The example usage of these usage can be found in the
90 * sub-directories below
92 template <class ServerInterface
>
102 /// Initialize the client communication endpoint with server.
103 int init (const char *name
, int argc
, ACE_TCHAR
*argv
[]);
105 /// Return the interface object pointer.
106 ServerInterface
*operator-> () { return server_
.in (); }
108 /// Returns the shutdown flag.
111 /// Fills in the shutdwon flag.
112 void do_shutdown (int);
114 /// Initialize naming service
115 int obtain_initial_references (const char *name
);
117 CORBA::ORB_ptr
orb ()
119 return CORBA::ORB::_duplicate (this->orb_
.in ());
123 /// Function to read the server IOR from a file.
124 int read_ior (ACE_TCHAR
*filename
);
126 /// Parses the arguments passed on the command line.
129 /// Remember our orb.
132 /// # of arguments on the command line.
135 /// arguments from command line.
138 /// IOR of the obj ref of the server.
142 typedef TAO_Intrusive_Ref_Count_Handle
<ServerInterface
> ServerInterface_var
;
143 ServerInterface_var server_
;
145 /// Flag to use the naming service
148 /// Flag for shutting down the server
152 #include "Simple_util.cpp"
153 #endif /* TAO_UTIL_H */