Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Concurrency / CC_tests.h
blobd07b084c718aad49dccf070b484fc375365c192d
2 //=============================================================================
3 /**
4 * @file CC_tests.h
6 * This class implements a number of test objects to test the
7 * concurrency service.
9 * @author Torben Worm <tworm@cs.wustl.edu>
11 //=============================================================================
14 #include "orbsvcs/CosConcurrencyControlC.h"
15 #include "orbsvcs/CosNamingC.h"
16 #include "CC_naming_service.h"
18 #ifndef _CC_TESTS_H_
19 #define _CC_TESTS_H_
21 // Return codes for the tests
22 enum
24 CC_FAIL,
25 CC_SUCCESS = 1
28 /**
29 * @class CC_Test
31 * @brief Defines an abstract base class for a test
33 * This class declares an interface to run the test of the
34 * concurrency service.
36 class CC_Test
38 public:
39 /// Default constructor
40 CC_Test (CC_naming_service *ns);
42 /// Destructor
43 virtual ~CC_Test ();
45 /// Run the test times_to_run number of times. Returns CC_SUCCESS on
46 /// success CC_FAIL otherwise.
47 virtual int run (int times_to_run = 1) = 0;
49 /// Create a new lock set using the default global lock set factory
50 /// from the naming service.
51 CosConcurrencyControl::LockSet_ptr create_lock_set ();
53 /// Returns a human readable string from the lock mode enum.
54 char *get_lock_mode_name (CosConcurrencyControl::lock_mode mode);
56 protected:
57 /// The result of the test being performed.
58 int result;
60 /// The naming service beeing used to register and look up locks
61 CC_naming_service *naming_service_;
64 /**
65 * @class Test_Single_Lock_With_Mode
67 * @brief This is a simple test that checks that it is possible to set
68 * the lock in the desired mode, try it, and release it.
70 class Test_Single_Lock_With_Mode : public CC_Test
72 public:
73 /**
74 * Default constructor. The naming service must be initialized
75 * before calling this method. The mode is the mode of the lock to
76 * be tested.
78 Test_Single_Lock_With_Mode (CC_naming_service *naming_service,
79 CosConcurrencyControl::lock_mode mode);
81 /// Destructor
82 virtual ~Test_Single_Lock_With_Mode ();
84 /// Runs the test the specified number of times.
85 virtual int run (int times_to_run = 1);
87 private:
88 /// The lock mode of the lock being tested
89 CosConcurrencyControl::lock_mode mode_;
92 /**
93 * @class Test_Setup_LockSet
95 * @brief This class creates a read lock, registeres it with the naming
96 * service and locks it.
98 class Test_Setup_LockSet : public CC_Test
100 public:
102 * Default constructor. The naming service must be initialized
103 * before calling this method. The name is the name the lock will be
104 * registered under in the naming service.
106 Test_Setup_LockSet (CC_naming_service *naming_service_,
107 char *name);
109 /// Destructor
110 virtual ~Test_Setup_LockSet ();
112 /// Runs the test the specified number of times.
113 virtual int run (int times_to_run = 1);
115 private:
116 /// The name of the lock
117 char *my_name_;
121 * @class Test_Use_Already_Created_LockSet
123 * @brief This class looks up the lock in the naming service and locks
124 * it.
126 class Test_Use_Already_Created_LockSet : public CC_Test
128 public:
130 * Default constructor. The naming service must be initialized
131 * before calling this method. The name is the name the lock will be
132 * looked up under in the naming service.
134 Test_Use_Already_Created_LockSet (CC_naming_service *naming_service_,
135 char *name);
137 /// Destructor
138 virtual ~Test_Use_Already_Created_LockSet ();
140 /// Runs the test the specified number of times.
141 virtual int run (int times_to_run = 1);
143 private:
144 /// The name of the lock
145 char *my_name_;
149 * @class Test_Unlock_Already_Created_LockSet
151 * @brief This class looks up the lock in the naming service and unlocks
152 * it.
154 class Test_Unlock_Already_Created_LockSet : public CC_Test
156 public:
158 * Default constructor. The naming service must be initialized
159 * before calling this method. The name is the name the lock will be
160 * looked up under in the naming service.
162 Test_Unlock_Already_Created_LockSet (CC_naming_service *naming_service_,
163 char *name);
165 /// Destructor
166 virtual ~Test_Unlock_Already_Created_LockSet ();
168 /// Runs the test the specified number of times.
169 virtual int run (int times_to_run = 1);
171 private:
172 /// The name of the lock
173 char *my_name_;
177 * @class Test_Release_Not_Held_Lock
179 * @brief This class tests that the LockNotHeld exception is thrown if a
180 * not held lock is released.
182 class Test_Release_Not_Held_Lock : public CC_Test
184 public:
185 /// Default constructor. The naming service must be initialized
186 /// before calling this method. The mode is the mode of the lock
187 Test_Release_Not_Held_Lock (CC_naming_service *naming_service_,
188 CosConcurrencyControl::lock_mode mode_);
190 /// Destructor
191 virtual ~Test_Release_Not_Held_Lock ();
193 /// Runs the test the specified number of times.
194 virtual int run (int times_to_run = 1);
196 private:
197 /// The lock mode of the lock being tested
198 CosConcurrencyControl::lock_mode mode_;
201 #endif /* !defined (_CC_TESTS_H_) */