Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / TAO / examples / Persistent_Grid / Simple_util.h
blobacb0aa284db1099a4a184bdf095244c668ab4f38
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 ();
38 /// Destructor.
39 ~Server ();
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 ();
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 ();
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 ();
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_;
82 // Client Class starts here
84 /**
85 * @class Client
87 * @brief Template Client class
89 * A template client implementation for a single server/client
90 * model. The example usage of these usage can be found in the
91 * sub-directories below
93 template <class InterfaceObj, class Var>
94 class Client
96 public:
97 /// Constructor.
98 Client ();
100 /// Destructor.
101 ~Client ();
103 /// Initialize the client communication endpoint with server.
104 int init (const char *name,int argc, ACE_TCHAR *argv[]);
106 /// Return the interface object pointer.
107 InterfaceObj *operator-> () { return server_.in ();};
109 /// Returns the shutdown flag.
110 int shutdown ();
112 /// Fills in the shutdwon flag.
113 void shutdown (int);
115 /// Initialize naming service
116 int obtain_initial_references ();
118 protected:
119 /// Function to read the server IOR from a file.
120 int read_ior (ACE_TCHAR *filename);
122 /// Parses the arguments passed on the command line.
123 int parse_args ();
125 /// Remember our orb.
126 CORBA::ORB_var orb_;
128 /// # of arguments on the command line.
129 int argc_;
131 /// arguments from command line.
132 ACE_TCHAR **argv_;
134 /// IOR of the obj ref of the server.
135 char *ior_;
137 /// Flag to use the naming service
138 int naming_;
140 /// Flag for shutting down the server
141 int shutdown_;
143 /// Server object
144 Var server_;
147 #include "Simple_util.cpp"
149 #endif /* TAO_UTIL_H */