=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / examples / OBV / Simple_util.h
blob32bfe42a5ae94cf7e7b68f5e29024a14a86bcd07
3 //=============================================================================
4 /**
5 * @file Simple_util.h
7 * The classe define the templates for the client and server.
9 * @author Balachandran Natarajan <bala@cs.wustl.edu>
11 //=============================================================================
14 #ifndef TAO_UTIL_H
15 #define TAO_UTIL_H
17 #include "tao/Utils/ORB_Manager.h"
19 #include "ace/Get_Opt.h"
20 #include "ace/Read_Buffer.h"
22 /**
23 * @class Server
25 * @brief A set of useful class Templates for using the TAO CORBA
26 * implementation.
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 implemenatation.
33 template <class Servant>
34 class Server
36 public:
37 /// Constructor.
38 Server ();
40 /// Destructor.
41 ~Server ();
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,
46 int argc,
47 ACE_TCHAR *argv[]);
49 /// After calling <init>, this method will register the server with
50 /// the TAO Naming Service using the servant_name passed to <init>.
51 int register_name ();
53 /// Run the orb.
54 int run ();
56 protected:
57 /// Servant class
58 Servant servant_;
60 /// name of the servant to be used for TAO Naming Service
61 const char *name;
63 /// Parses the commandline arguments.
64 int parse_args ();
66 /// The ORB manager - a helper class for accessing the POA and
67 /// registering objects.
68 TAO_ORB_Manager orb_manager_;
70 // TAO_Naming_Server namingServer;
71 // helper class for getting access to Naming Service.
73 /// File where the IOR of the server object is stored.
74 FILE *ior_output_file_;
76 /// Number of command line arguments.
77 int argc_;
79 /// The command line arguments.
80 ACE_TCHAR **argv_;
83 /**
84 * @class Client
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 InterfaceObj, class Var>
93 class Client
95 public:
96 /// Constructor.
97 Client ();
99 /// Destructor.
100 ~Client ();
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 InterfaceObj *operator-> () { return server_.in ();};
108 /// Returns the shutdown flag.
109 int shutdown ();
111 /// Fills in the shutdwon flag.
112 void shutdown (int);
114 /// Initialize naming service
115 int obtain_initial_references ();
117 protected:
118 /// Function to read the server IOR from a file.
119 int read_ior (ACE_TCHAR *filename);
121 /// Parses the arguments passed on the command line.
122 int parse_args ();
124 // TAO_Naming_Client namingClient;
125 // helper class for getting access to Naming Service.
127 /// # of arguments on the command line.
128 int argc_;
130 /// arguments from command line.
131 ACE_TCHAR **argv_;
133 /// IOR of the obj ref of the server.
134 char *ior_;
136 /// Name to be usred for the naming service
137 char *name_;
139 /// Remember our orb.
140 CORBA::ORB_var orb_;
142 /// Server object
143 Var server_;
145 /// Flag to use the naming service
146 int naming_;
148 /// Flag for shutting down the server
149 int shutdown_;
152 #include "Simple_util.cpp"
154 #endif /* TAO_UTIL_H */