Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / OBV / Simple / Simple_util.h
blobacf966cf5d7b08cec38646f29bf815e22b96f8fc
1 //=============================================================================
2 /**
3 * @file Simple_util.h
5 * The classe define the templates for the client and server.
7 * @author Balachandran Natarajan <bala@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_UTIL_H
12 #define TAO_UTIL_H
14 #include "tao/Utils/ORB_Manager.h"
16 #include "ace/Get_Opt.h"
17 #include "ace/Read_Buffer.h"
19 /**
20 * @class Server
22 * @brief A set of useful class Templates for using the TAO CORBA
23 * implementation.
25 * A template server definition. This template can be used by
26 * single server/client projects for definition of their
27 * server/clients. See the directories time, bank, echo for
28 * further details of implemenatation.
30 template <class Servant>
31 class Server
33 public:
34 /// Constructor.
35 Server ();
37 /// Destructor.
38 ~Server ();
40 /// Initialize the Server state - parsing arguments and waiting.
41 /// interface_name is the name used to register the Servant.
42 int init (const char *servant_name,
43 int argc,
44 ACE_TCHAR *argv[]);
46 /// After calling <init>, this method will register the server with
47 /// the TAO Naming Service using the servant_name passed to <init>.
48 int register_name ();
50 /// Run the orb.
51 int run ();
53 protected:
54 /// Servant class
55 Servant servant_;
57 /// name of the servant to be used for TAO Naming Service
58 const char *name;
60 /// Parses the commandline arguments.
61 int parse_args ();
63 /// The ORB manager - a helper class for accessing the POA and
64 /// registering objects.
65 TAO_ORB_Manager orb_manager_;
67 // TAO_Naming_Server namingServer;
68 // helper class for getting access to Naming Service.
70 /// File where the IOR of the server object is stored.
71 FILE *ior_output_file_;
73 /// Number of command line arguments.
74 int argc_;
76 /// The command line arguments.
77 ACE_TCHAR **argv_;
80 /**
81 * @class Client
83 * @brief Template Client class
85 * A template client implementation for a single server/client
86 * model. The example usage of these usage can be found in the
87 * sub-directories below
89 template <class InterfaceObj, class Var>
90 class Client
92 public:
93 /// Constructor.
94 Client ();
96 /// Destructor.
97 ~Client ();
99 /// Initialize the client communication endpoint with server.
100 int init (const char *name,int argc, ACE_TCHAR *argv[]);
102 /// Return the interface object pointer.
103 InterfaceObj *operator-> () { return server_.in ();};
105 /// Returns the shutdown flag.
106 int shutdown ();
108 /// Fills in the shutdwon flag.
109 void shutdown (int);
111 /// Initialize naming service
112 int obtain_initial_references ();
114 protected:
115 /// Function to read the server IOR from a file.
116 int read_ior (ACE_TCHAR *filename);
118 /// Parses the arguments passed on the command line.
119 int parse_args ();
121 // TAO_Naming_Client namingClient;
122 // helper class for getting access to Naming Service.
124 /// # of arguments on the command line.
125 int argc_;
127 /// arguments from command line.
128 ACE_TCHAR **argv_;
130 /// IOR of the obj ref of the server.
131 ACE_TCHAR *ior_;
133 /// Name to be usred for the naming service
134 char *name_;
136 /// Remember our orb.
137 CORBA::ORB_var orb_;
139 /// Server object
140 Var server_;
142 /// Flag to use the naming service
143 int naming_;
145 /// Flag for shutting down the server
146 int shutdown_;
149 #include "Simple_util.cpp"
150 #endif /* TAO_UTIL_H */