Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / examples / Persistent_Grid / Simple_util.h
blob4742ba66d37383e49c89d6e217645cf46eb00fac
2 //=============================================================================
3 /**
4 * @file Simple_util.h
6 * The classe define the templates for the client and server.
8 * @author Balachandran Natarajan <bala@cs.wustl.edu>
9 */
10 //=============================================================================
13 #ifndef TAO_UTIL_H
14 #define TAO_UTIL_H
16 #include "tao/Utils/ORB_Manager.h"
17 #include "ace/Get_Opt.h"
18 #include "ace/Read_Buffer.h"
20 /**
21 * @class Server
23 * @brief A set of useful class Templates for using the TAO CORBA
24 * implementation.
26 * A template server definition. This template can be used by
27 * single server/client projects for definition of their
28 * server/clients. See the directories time, bank, echo for
29 * further details of implemenatation.
31 template <class Servant>
32 class Server
34 public:
35 /// Constructor.
36 Server (void);
38 /// Destructor.
39 ~Server (void);
41 /// Initialize the Server state - parsing arguments and waiting.
42 /// interface_name is the name used to register the Servant.
43 int init (const char *servant_name,
44 int argc,
45 ACE_TCHAR *argv[]);
47 // int register_name (void);
48 // After calling <init>, this method will register the server with
49 // the TAO Naming Service using the servant_name passed to <init>.
51 /// Run the orb.
52 int run (void);
54 protected:
55 /// Servant class
56 Servant servant_;
58 /// name of the servant to be used for TAO Naming Service
59 const char *name;
61 /// Parses the commandline arguments.
62 int parse_args (void);
64 /// The ORB manager - a helper class for accessing the POA and
65 /// registering objects.
66 TAO_ORB_Manager orb_manager_;
68 /// File where the IOR of the server object is stored.
69 FILE *ior_output_file_;
71 /// Memory pool name that stores the state
72 ACE_TCHAR* mem_pool_name_;
74 /// Number of command line arguments.
75 int argc_;
77 /// The command line arguments.
78 ACE_TCHAR **argv_;
83 // Client Class starts here
85 /**
86 * @class Client
88 * @brief Template Client class
90 * A template client implementation for a single server/client
91 * model. The example usage of these usage can be found in the
92 * sub-directories below
94 template <class InterfaceObj, class Var>
95 class Client
97 public:
98 /// Constructor.
99 Client (void);
101 /// Destructor.
102 ~Client (void);
104 /// Initialize the client communication endpoint with server.
105 int init (const char *name,int argc, ACE_TCHAR *argv[]);
107 /// Return the interface object pointer.
108 InterfaceObj *operator-> () { return server_.in ();};
110 /// Returns the shutdown flag.
111 int shutdown (void );
113 /// Fills in the shutdwon flag.
114 void shutdown (int);
116 /// Initialize naming service
117 int obtain_initial_references (void);
119 protected:
120 /// Function to read the server IOR from a file.
121 int read_ior (ACE_TCHAR *filename);
123 /// Parses the arguments passed on the command line.
124 int parse_args (void);
126 /// Remember our orb.
127 CORBA::ORB_var orb_;
129 /// # of arguments on the command line.
130 int argc_;
132 /// arguments from command line.
133 ACE_TCHAR **argv_;
135 /// IOR of the obj ref of the server.
136 char *ior_;
138 /// Flag to use the naming service
139 int naming_;
141 /// Flag for shutting down the server
142 int shutdown_;
144 /// Server object
145 Var server_;
148 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
149 #include "Simple_util.cpp"
150 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
151 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
152 #pragma implementation ("Simple_util.cpp")
153 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
155 #endif /* TAO_UTIL_H */