ACE+TAO-7_0_8
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / tao_imr_i.h
blobacdcc910380708d7152a9232b2b5c281921761e1
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file tao_imr_i.h
7 * This class implements the Implementation Repository helper application.
9 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
11 //=============================================================================
12 #ifndef TAO_IMR_I_H
13 #define TAO_IMR_I_H
15 #include "tao/ImR_Client/ImplRepoC.h"
16 #include "tao/corba.h"
17 #include "ace/SString.h"
18 #include "ace/Auto_Ptr.h"
20 // Forward Declaration
21 class TAO_IMR_Op;
23 /**
24 * @class TAO_IMR_i
26 * @brief TAO's command line helper application
28 * This class talks to the IMR and registers/lists/etc.
30 class TAO_IMR_i
32 public:
34 // = Constructor and destructor.
35 TAO_IMR_i (void);
36 ~TAO_IMR_i (void);
38 /// Execute client code.
39 int run (void);
41 /// Initialize the client communication endpoint with server.
42 int init (int argc, ACE_TCHAR **argv);
44 private:
45 /// Print out information about all operations.
46 void print_usage (void);
48 /// Parses the arguments passed on the command line.
49 int parse_args (void);
51 /// # of arguments on the command line.
52 int argc_;
54 /// Arguments from command line.
55 ACE_TCHAR **argv_;
57 /// Remember our orb.
58 CORBA::ORB_var orb_;
60 /// Reference to our Locator interface of
61 /// implementation repository.
62 ImplementationRepository::Administration_var imr_;
64 /// What we need to do.
65 ACE_Auto_Ptr<TAO_IMR_Op> op_;
69 /**
70 * @class TAO_IMR_Op
72 * @brief IMR Operation Base Class
74 * Provides a base class with virtual methods for each operation strategy.
76 class TAO_IMR_Op
78 public:
79 enum RETURN_CODES {
80 NORMAL = 0,
81 UNKNOWN,
82 NO_PERMISSION,
83 ALREADY_REGISTERED,
84 CANNOT_ACTIVATE,
85 NOT_FOUND,
86 CANNOT_COMPLETE
89 /// Factory.
90 static TAO_IMR_Op *make_op (const ACE_TCHAR *op_name);
92 /// Destructor.
93 virtual ~TAO_IMR_Op (void);
95 /// Parse arguments.
96 virtual int parse (int argc, ACE_TCHAR **argv) = 0;
98 /// Do the work.
99 virtual int run (void) = 0;
101 /// Sets the implrepo locator pointer
102 void set_imr (ImplementationRepository::Administration_ptr imr);
104 protected:
105 TAO_IMR_Op (void) : imr_ (0), quiet_ (false) {}
107 // = Helper methods
109 /// Prints out the information contained in a ServerInformation structure.
110 void display_server_information (const ImplementationRepository::ServerInformation &info);
112 /// Reference to our implementation repository.
113 ImplementationRepository::Administration_ptr imr_;
114 bool quiet_;
119 * @class TAO_IMR_Op_Activate
121 * @brief Activation Operation
123 * Activation is used to start servers via the Implementation Repository
125 class TAO_IMR_Op_Activate : public TAO_IMR_Op
127 public:
128 virtual int parse (int argc, ACE_TCHAR **argv);
129 virtual int run (void);
131 protected:
132 /// Prints a message about the usage
133 void print_usage (void);
135 /// POA server name.
136 ACE_CString server_name_;
140 * @class TAO_IMR_Op_Autostart
142 * @brief Autostart Operation
144 * Autostart is used to activate all servers with the AUTO_START activation
145 * mode.
147 class TAO_IMR_Op_Autostart : public TAO_IMR_Op
149 public:
150 virtual int parse (int argc, ACE_TCHAR **argv);
151 virtual int run (void);
153 protected:
154 /// Prints a message about the usage
155 void print_usage (void);
160 * @class TAO_IMR_Op_IOR
162 * @brief IOR Operation
164 * IOR is used to create a simple IOR for a server that uses the
165 * IMR and the Interoperable Naming Service.
167 class TAO_IMR_Op_IOR : public TAO_IMR_Op
169 public:
170 virtual int parse (int argc, ACE_TCHAR **argv);
171 virtual int run (void);
173 protected:
174 /// Prints a message about the usage
175 void print_usage (void);
177 /// POA server name.
178 ACE_CString server_name_;
180 /// Filename to output to.
181 ACE_TString filename_;
186 * @class TAO_IMR_Op_Kill
188 * @brief Kill Operation
190 * Kill is used to unregister a server in the IMR.
192 class TAO_IMR_Op_Kill : public TAO_IMR_Op
194 public:
195 virtual int parse (int argc, ACE_TCHAR **argv);
196 virtual int run (void);
198 protected:
199 /// Prints a message about the usage
200 void print_usage (void);
202 ACE_CString server_name_;
203 int signum_;
208 * @class TAO_IMR_Op_Link
210 * @brief Link Operation
212 * Link is used to unregister a server in the IMR.
214 class TAO_IMR_Op_Link : public TAO_IMR_Op
216 public:
217 virtual int parse (int argc, ACE_TCHAR **argv);
218 virtual int run (void);
220 protected:
221 /// Prints a message about the usage
222 void print_usage (void);
224 ACE_CString server_name_;
226 CORBA::StringSeq peers_;
232 * @class TAO_IMR_Op_List
234 * @brief List Operation
236 * List is used to either list all the servers registered in the IMR or just
237 * look at one of them.
239 class TAO_IMR_Op_List : public TAO_IMR_Op
241 public:
242 TAO_IMR_Op_List (void);
244 virtual int parse (int argc, ACE_TCHAR **argv);
245 virtual int run (void);
247 protected:
248 /// Prints a message about the usage
249 void print_usage (void);
251 /// POA server name.
252 ACE_CString server_name_;
254 /// If true, more server information is displayed.
255 int verbose_server_information_;
257 /// If true, only show servers that are currently active.
258 int list_only_active_servers_;
260 /// retrieve no more than this number of entries at a time
261 CORBA::ULong how_many_;
263 /// If true, use minimum formatting.
264 int terse_;
266 /// Prints out the information contained in a ServerInformation structure.
267 /// Specialized to only print server information
268 void display_server_information (const ImplementationRepository::ServerInformation &info);
273 * @class TAO_IMR_Op_Remove
275 * @brief Remove Operation
277 * Remove is used to unregister a server in the IMR.
279 class TAO_IMR_Op_Remove : public TAO_IMR_Op
281 public:
282 virtual int parse (int argc, ACE_TCHAR **argv);
283 virtual int run (void);
285 protected:
286 /// Prints a message about the usage
287 void print_usage (void);
289 ACE_CString server_name_;
290 bool force_;
291 int signum_;
296 * @class TAO_IMR_Op_Shutdown
298 * @brief Shutdown Operation
300 * Shutdown is used to shutdown a server through the IMR.
302 class TAO_IMR_Op_Shutdown : public TAO_IMR_Op
304 public:
305 virtual int parse (int argc, ACE_TCHAR **argv);
306 virtual int run (void);
308 protected:
309 /// Prints a message about the usage
310 void print_usage (void);
312 ACE_CString server_name_;
316 * Shutdown the ImR and optionally any registered activators.
318 class TAO_IMR_Op_ShutdownRepo : public TAO_IMR_Op
320 public:
321 TAO_IMR_Op_ShutdownRepo();
322 virtual int parse (int argc, ACE_TCHAR **argv);
323 virtual int run (void);
325 protected:
326 void print_usage (void);
328 bool activators_;
332 * @class TAO_IMR_Op_Register
334 * @brief Register Operation
336 * Register is used to update/add information for a server
337 * with the IMR.
339 class TAO_IMR_Op_Register : public TAO_IMR_Op
341 public:
342 TAO_IMR_Op_Register(bool is_add);
344 virtual int parse (int argc, ACE_TCHAR **argv);
345 virtual int run (void);
347 protected:
349 /// Enables pre-registration checks
350 bool is_add_;
352 /// Sets one environment variable.
353 void addenv (ACE_TCHAR *opt);
355 /// Prints a message about the usage.
356 void print_usage (void);
358 /// POA server name.
359 ACE_CString server_name_;
361 bool set_command_line_;
362 ACE_CString command_line_;
364 bool set_environment_vars_;
365 ImplementationRepository::EnvironmentList environment_vars_;
367 bool set_working_dir_;
368 ACE_CString working_dir_;
370 bool set_activation_;
371 ImplementationRepository::ActivationMode activation_;
373 bool set_retry_count_;
374 int retry_count_;
376 bool set_activator_;
377 ACE_CString activator_;
380 #endif /* TAO_IMR_I_H */