Merge pull request #2318 from jwillemsen/jwi-add_forward_profiles
[ACE_TAO.git] / TAO / orbsvcs / tests / Concurrency / CC_command.h
blob3e322c09dac78a349dc88425f2e33c2e2395ac4d
2 //=============================================================================
3 /**
4 * @file CC_command.h
6 * This file implements the command possible to execute on the
7 * concurrency service's lock set interface. The file also contains
8 * an implementation of a command list used by the command parser to
9 * store the commands to be executed.
11 * @author Torben Worm <tworm@cs.wustl.edu>
13 //=============================================================================
16 #include "orbsvcs/CosConcurrencyControlC.h"
18 #ifndef _CC_COMMAND_H_
19 #define _CC_COMMAND_H_
21 /**
22 * @class CC_Command
24 * @brief Defines an abstact class for the commands towards the lock set
26 * This class declares an interface to run a test towards one or more
27 * lock sets in the concurrency service. The class provides a virtual
28 * execute method that is common for all its subclasses. It is also the
29 * the base class for the auxillary commands start, wait, and sleep.
31 class CC_Command
33 public:
34 /// Destructor
35 virtual ~CC_Command();
37 /// Abstract execute method
38 virtual int execute() = 0;
40 protected:
41 /// Function to look up the lock set we are operating on, or if the
42 /// name is "" return the global lock set variable
43 CosConcurrencyControl::LockSet_var
44 GetLockSet (const char *lock_set_name);
46 /// Default constructor. We do not want instances of this class
47 CC_Command();
49 /**
50 * The last exception raised in one of the test commands. This variable
51 * is checked by all commands in order to determine if an exception has
52 * been raised. This is necessary because sometimes we want to check that
53 * an event caused an exception (done by the CC_Excep_Cmd command class)
54 * as part of the testing.
56 static CORBA::Exception *excep_;
58 /// This is the default lock set. The variable is either set by a create
59 /// command without name or by the lookup command.
60 static CosConcurrencyControl::LockSet_var cc_lockset_;
62 private:
65 /**
66 * @class CC_Start_Cmd
68 * @brief Defines a class for the start command
70 * This class represents the start command. The start command is used
71 * to start a new process with another script file in order to test the
72 * aspects of the concurrency service that requires several processes
73 * running at the same time.
75 class CC_Start_Cmd : public CC_Command
77 public:
78 /// Constructor
79 CC_Start_Cmd (const char *config_file_name);
81 /// Destructor
82 virtual ~CC_Start_Cmd();
84 /// Start the child process. The current version does not wait for the
85 /// process to terminate.
86 virtual int execute();
88 private:
89 /// The name of the script file
90 char *cfg_name_;
93 /**
94 * @class CC_CreateLockSet_Cmd
96 * @brief Defines a class for the create command on the lock set factory
98 * This class represents the create command on the lock set factory.
99 * The lock set is registered in the naming service with the provided
100 * name.
102 class CC_CreateLockSet_Cmd : public CC_Command
104 public:
105 /// Constructor
106 CC_CreateLockSet_Cmd (const char *lock_set_name);
108 /// Destructor
109 virtual ~CC_CreateLockSet_Cmd ();
111 /// Executes the command, i.e. creates the lock set and binds the name
112 /// in the naming service.
113 virtual int execute();
115 private:
116 /// The name used to bind in the naming service.
117 char *name_;
121 * @class CC_Lock_Cmd:public
123 * @brief Defines a class for the lock command on the lock set
125 * This class represents the lock command on the lock set. The lock set
126 * is looked up in the naming service.
128 class CC_Lock_Cmd:public CC_Command
130 public:
131 /// Constructor.
132 CC_Lock_Cmd(const char *lock_set_name,
133 CosConcurrencyControl::lock_mode mode);
135 /// Destructor
136 virtual ~CC_Lock_Cmd();
138 /// Executes the command, i.e. looks up the lock set with the requested
139 /// name in the naming server and executes the lock command on that lock set.
140 virtual int execute();
142 private:
143 /// The name to look up in the naming service.
144 char *name_;
146 /// The mode of the lock.
147 CosConcurrencyControl::lock_mode mode_;
151 * @class CC_UnLock_Cmd:public
153 * @brief Defines a class for the unlock command on the lock set
155 * This class represents the unlock command on the lock set. The lock set
156 * is looked up in the naming service.
158 class CC_UnLock_Cmd:public CC_Command
160 public:
161 /// Constructor.
162 CC_UnLock_Cmd(const char *lock_set_name,
163 CosConcurrencyControl::lock_mode mode);
165 /// Destructor
166 virtual ~CC_UnLock_Cmd();
169 * Executes the command, i.e. looks up the lock set with the requested
170 * name in the naming server and executes the unlock command on that
171 * lock set.
173 virtual int execute();
175 private:
176 /// The name to look up in the naming service.
177 char *name_;
179 /// The mode of the lock.
180 CosConcurrencyControl::lock_mode mode_;
184 * @class CC_TryLock_Cmd:public
186 * @brief Defines a class for the try_lock command on the lock set
188 * This class represents the try_lock command on the lock set. The lock set
189 * is looked up in the naming service.
191 class CC_TryLock_Cmd:public CC_Command
193 public:
194 /// Constructor
195 CC_TryLock_Cmd(const char *lock_set_name,
196 CosConcurrencyControl::lock_mode mode);
198 /// Destructor
199 virtual ~CC_TryLock_Cmd();
202 * Executes the command, i.e. looks up the lock set with the requested
203 * name in the naming server and executes the try_lock command on that
204 * lock set.
206 virtual int execute();
208 private:
209 /// The name to look up in the naming service.
210 char *name_;
212 /// The mode of the lock.
213 CosConcurrencyControl::lock_mode mode_;
217 * @class CC_ChangeMode_Cmd:public
219 * @brief Defines a class for the change_mode command on the lock set
221 * This class represents the change_mode command on the lock set.
222 * The lock set is looked up in the naming service.
224 class CC_ChangeMode_Cmd:public CC_Command
226 public:
227 /// Constructor
228 CC_ChangeMode_Cmd (const char *lock_set_name,
229 CosConcurrencyControl::lock_mode held_mode,
230 CosConcurrencyControl::lock_mode new_mode);
232 /// Destructor
233 virtual ~CC_ChangeMode_Cmd();
236 * Executes the command, i.e. looks up the lock set with the requested
237 * name in the naming server and executes the change_mode command on that
238 * lock set.
240 virtual int execute();
242 private:
243 /// The name to look up in the naming service.
244 char *name_;
246 /// The mode of the held lock
247 CosConcurrencyControl::lock_mode held_mode_;
249 /// The new mode of the lock
250 CosConcurrencyControl::lock_mode new_mode_;
254 * @class CC_Sleep_Cmd:public
256 * @brief Defines a class for the sleep command
258 * This class represents the sleep command. This command is used to make
259 * the script pause for the requested number of second, e.g. to wait for
260 * another process to start.
262 class CC_Sleep_Cmd:public CC_Command
264 public:
265 /// Constructor.
266 CC_Sleep_Cmd(int seconds);
268 /// Destructor.
269 virtual ~CC_Sleep_Cmd();
271 /// Executes the command.
272 virtual int execute();
274 private:
275 /// The number of seconds to sleep
276 int time_;
280 * @class CC_Repeat_Cmd:public
282 * @brief Defines a class for the repeat command
284 * This class represents the repeat command. This command is used to make
285 * the script repeat the test the requested number of times.
286 * The command is curently NOT implemented.
288 class CC_Repeat_Cmd:public CC_Command
290 public:
291 /// Constructor.
292 CC_Repeat_Cmd(int times);
294 /// Destructor.
295 virtual ~CC_Repeat_Cmd();
297 /// Executes the command.
298 virtual int execute();
299 private:
300 /// The number of times the commands should be repeated
301 int times_;
305 * @class CC_Wait_Cmd:public
307 * @brief Defines a class for the wait command
309 * This class represents the wait command. This command is used to make
310 * the script wait for the user to press return. It is possible to print
311 * different prompts, e.g. instructions.
313 class CC_Wait_Cmd:public CC_Command
315 public:
316 /// Constructor.
317 CC_Wait_Cmd (const char *prompt);
319 /// Destructor.
320 virtual ~CC_Wait_Cmd();
322 /// Executes the command.
323 virtual int execute();
325 private:
326 /// The prompt to print on the screen
327 char *prompt_;
331 * @class CC_Excep_Cmd
333 * @brief Defines a class for the excep command
335 * This class represents the excep command. This command is used to make
336 * the script capable of dealing with cases where an exception is raised
337 * as part of the testing.
339 class CC_Excep_Cmd : public CC_Command
341 public:
342 /// Constructor.
343 CC_Excep_Cmd (const char *excep);
345 /// Destructor.
346 virtual ~CC_Excep_Cmd();
349 * Executes the command. Checks to see if the excep_ class variable is set,
350 * and if that's the case check that it is of the expected type. If not the
351 * test fails.
353 virtual int execute();
355 private:
356 /// The string representation of the expected exception
357 char *ex_;
361 * @class CC_Dummy_Cmd:
363 * @brief Defines a class for the dummy command
365 * This class represents the dummy command. This command is used to
366 * put in a command in the chain that does nothing.
368 class CC_Dummy_Cmd: public CC_Command
370 public:
371 /// Constructor.
372 CC_Dummy_Cmd();
374 /// Destructor.
375 virtual ~CC_Dummy_Cmd();
377 /// Executes the command, i.e. does nothing.
378 virtual int execute();
380 private:
384 * @class CC_Print_Cmd:
386 * @brief Defines a class for the print command
388 * This class represents the print command. This command is used to
389 * print a message on stdout
391 class CC_Print_Cmd: public CC_Command
393 public:
394 /// Constructor.
395 CC_Print_Cmd (const char *message);
397 /// Destructor.
398 virtual ~CC_Print_Cmd();
400 /// Executes the command.
401 virtual int execute();
403 private:
404 /// Holds the message to print
405 char *msg_;
409 * @class CC_Lookup_Cmd:public
411 * @brief Defines a class for the lookup command.
413 * This class represents the lookup command. The lock set
414 * is looked up in the naming service and the class variable
415 * cc_lockset_ is set accordingly.
417 class CC_Lookup_Cmd:public CC_Command
419 public:
420 /// Constructor
421 CC_Lookup_Cmd (const char *lock_set_name);
423 /// Destructor
424 virtual ~CC_Lookup_Cmd();
426 /// Executes the command, i.e. looks up the lock set with the requested
427 /// name in the naming server and sets the cc_lockset_ variable.
428 virtual int execute();
430 private:
431 /// The name to look up in the naming service.
432 char *name_;
436 * @class CC_CommandElem
438 * @brief Defines a class for a command element
440 * This class implements a command element used in the command list
441 * below. The class is a simple tupple holding a pointer to the command
442 * and a pointer to the next element in the list.
444 class CC_CommandElem
446 public:
447 /// Constructor.
448 CC_CommandElem (CC_Command *cmd, CC_CommandElem *next);
450 /// Destructor.
451 ~CC_CommandElem();
453 /// Returns a pointer to the command in this element
454 CC_Command *GetCommand();
456 /// Returns the pointer to the next element
457 CC_CommandElem *GetNext();
459 /// Sets the next pointer
460 void SetNext(CC_CommandElem *next);
462 private:
463 /// Pointer to the next element
464 CC_CommandElem *next_;
466 /// Pointer to the command element
467 CC_Command *cmd_;
471 * @class CC_CommandList
473 * @brief Defines a class for a command list
475 * This class implements a command list used from the script parser
476 * to store the parsed commands The class implements a simple single
477 * linked list.
479 class CC_CommandList
481 public:
482 /// Constructor.
483 CC_CommandList();
485 /// Destructor.
486 ~CC_CommandList();
488 /// Adds the command to the list
489 int add(CC_Command *cmd);
491 /// Executes all the commands in the list from head to tail
492 int execute();
494 /// Sets the number of times to repeat the script
495 void setrepeat(int times);
497 private:
498 /// The head of the command list
499 CC_CommandElem *head_;
501 /// The last inserted element
502 CC_CommandElem *last_;
504 /// The number of times the script should be repeated
505 int times_;
508 #endif /* _CC_COMMAND_H_ */