2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \brief This file contains declaration of common APIs for NS_UtilityCenter.
20 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 * @file ns_utility_sys.hpp
26 #ifndef __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__ // NOLINT (build/header_guard)
27 #define __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__
29 #include <native_service/frameworkunified_types.h>
30 #include <native_service/ns_utility.hpp>
34 /** @addtogroup BaseSystem
37 /** @addtogroup native_service
41 /** @addtogroup framework_unified
42 * @ingroup native_service
45 /** @addtogroup native
46 * @ingroup framework_unified
50 // Lock Wrapper ////////////////////////////////////////////////////////////////
53 * \~english define the lock_error class inherit from std::runtime_error
55 DEFINE_EXCEPTION(lock_error, std::runtime_error);
58 * \~english define the lock_creation_error class inherit from lock_error
60 DEFINE_EXCEPTION(lock_creation_error, lock_error);
63 * \~english define the lock_acquireread_error class inherit from lock_error
65 DEFINE_EXCEPTION(lock_acquireread_error, lock_error);
68 * \~english define the lock_acquirewrite_error class inherit from lock_error
70 DEFINE_EXCEPTION(lock_acquirewrite_error, lock_error);
73 * \~english define the lock_release_error class inherit from lock_error
75 DEFINE_EXCEPTION(lock_release_error, lock_error);
80 * @brief \~english Mutex Lock Class
81 * @par \~english Brief Introduction
82 * \~english This class defines locking policy for Mutexes.
87 ////////////////////////////////////////////////////////////////////////////////////////////////
88 /// \ingroup NS_UtilityCenter
89 /// \~english @par Brief
90 /// Construct a CMutex object.
91 /// \~english @par Prerequisite
93 /// \~english @par Change of internal state
95 /// \~english @par Conditions of processing failure
97 /// \~english @par Classification
99 /// \~english @par Type
101 /// \~english @par Detail
102 /// The function constructs a CMutex object.
104 ////////////////////////////////////////////////////////////////////////////////////////////////
107 ////////////////////////////////////////////////////////////////////////////////////////////////
108 /// \ingroup NS_UtilityCenter
109 /// \~english @par Brief
110 /// Destruct the CMutex object.
111 /// \~english @par Prerequisite
112 /// - Construct a CMutex object
113 /// \~english @par Change of internal state
115 /// \~english @par Conditions of processing failure
117 /// \~english @par Classification
119 /// \~english @par Type
121 /// \~english @par Detail
122 /// The function destructs the CMutex object.
123 /// \~english @see CMutex()
124 ////////////////////////////////////////////////////////////////////////////////////////////////
127 ////////////////////////////////////////////////////////////////////////////////////////////////
128 /// \ingroup NS_UtilityCenter
129 /// \~english @par Brief
130 /// Lock the CMutex object when reading.
131 /// \~english @retval void
133 /// \~english @par Prerequisite
134 /// - Construct a CMutex object
135 /// \~english @par Change of internal state
137 /// \~english @par Conditions of processing failure
139 /// \~english @par Classification
141 /// \~english @par Type
143 /// \~english @par Detail
144 /// The function locks the CMutex object when reading.
145 /// \~english @see CMutex(), WriteLock(), UnLock()
146 ////////////////////////////////////////////////////////////////////////////////////////////////
149 ////////////////////////////////////////////////////////////////////////////////////////////////
150 /// \ingroup NS_UtilityCenter
151 /// \~english @par Brief
152 /// Lock the CMutex object when writing.
153 /// \~english @retval void
155 /// \~english @par Prerequisite
156 /// - Construct a CMutex object
157 /// \~english @par Change of internal state
159 /// \~english @par Conditions of processing failure
161 /// \~english @par Classification
163 /// \~english @par Type
165 /// \~english @par Detail
166 /// The function locks the CMutex object when writing.
167 /// \~english @see CMutex(), ReadLock(), UnLock()
168 ////////////////////////////////////////////////////////////////////////////////////////////////
171 ////////////////////////////////////////////////////////////////////////////////////////////////
172 /// \ingroup NS_UtilityCenter
173 /// \~english @par Brief
174 /// Open the lock of the CMutex object.
175 /// \~english @retval void
177 /// \~english @par Prerequisite
178 /// - Construct a CMutex object
179 /// \~english @par Change of internal state
181 /// \~english @par Conditions of processing failure
183 /// \~english @par Classification
185 /// \~english @par Type
187 /// \~english @par Detail
188 /// The function opens the lock of the CMutex object.
189 /// \~english @see CMutex(), ReadLock(), WriteLock()
190 ////////////////////////////////////////////////////////////////////////////////////////////////
195 pthread_mutex_t m_mtx;
200 * @brief \~english Read/Write Lock Class
201 * @par \~english Brief Introduction
202 * \~english This class defines locking policy for reader/writer.
207 ////////////////////////////////////////////////////////////////////////////////////////////////
208 /// \ingroup NS_UtilityCenter
209 /// \~english @par Brief
210 /// - Construct a CRWLock object.
211 /// \~english @par Prerequisite
213 /// \~english @par Change of internal state
215 /// \~english @par Conditions of processing failure
217 /// \~english @par Classification
219 /// \~english @par Type
221 /// \~english @par Detail
222 /// The function constructs a CRWLock object.
223 /// \~english @see ~CRWLock()
224 ////////////////////////////////////////////////////////////////////////////////////////////////
227 ////////////////////////////////////////////////////////////////////////////////////////////////
228 /// \ingroup NS_UtilityCenter
229 /// \~english @par Brief
230 /// Destruct the CRWLock object.
231 /// \~english @par Prerequisite
232 /// - Construct a CRWLock object.
233 /// \~english @par Change of internal state
235 /// \~english @par Conditions of processing failure
237 /// \~english @par Classification
239 /// \~english @par Type
241 /// \~english @par Detail
242 /// The function destructs the CRWLock object.
243 /// \~english @see CRWLock()
244 ////////////////////////////////////////////////////////////////////////////////////////////////
247 ////////////////////////////////////////////////////////////////////////////////////////////////
248 /// \ingroup NS_UtilityCenter
249 /// \~english @par Brief
250 /// Lock the CRWLock object when reading.
251 /// \~english @retval void
253 /// \~english @par Prerequisite
254 /// - Construct a CRWLock object.
255 /// \~english @par Change of internal state
257 /// \~english @par Conditions of processing failure
259 /// \~english @par Classification
261 /// \~english @par Type
263 /// \~english @par Detail
264 /// The function locks the CRWLock object when reading.
265 /// \~english @see CRWLock(), WriteLock(), UnLoack()
266 ////////////////////////////////////////////////////////////////////////////////////////////////
269 ////////////////////////////////////////////////////////////////////////////////////////////////
270 /// \ingroup NS_UtilityCenter
271 /// \~english @par Brief
272 /// Lock the CRWLock object when writing.
273 /// \~english @retval void
275 /// \~english @par Prerequisite
276 /// - Construct a CRWLock object.
277 /// \~english @par Change of internal state
279 /// \~english @par Conditions of processing failure
281 /// \~english @par Classification
283 /// \~english @par Type
285 /// \~english @par Detail
286 /// The function locks the CRWLock object when writing.
287 /// \~english @see CRWLock(), ReadLock(), UnLock()
288 ////////////////////////////////////////////////////////////////////////////////////////////////
291 ////////////////////////////////////////////////////////////////////////////////////////////////
292 /// \ingroup NS_UtilityCenter
293 /// \~english @par Brief
294 /// Open the lock of CRWLock object
295 /// \~english @retval void
297 /// \~english @par Prerequisite
298 /// - Construct a CRWLock object.
299 /// \~english @par Change of internal state
301 /// \~english @par Conditions of processing failure
303 /// \~english @par Classification
305 /// \~english @par Type
307 /// \~english @par Detail
308 /// The function opens the lock of the CRWLock object.
309 /// \~english @see CRWLock(), ReadLock(), WriteLock()
310 ////////////////////////////////////////////////////////////////////////////////////////////////
314 pthread_rwlock_t m_rwl;
317 #endif // __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__ // NOLINT (build/header_guard)
318 /** @}*/ // end of native
319 /** @}*/ // end of framework_unified
320 /** @}*/ // end of native_service
321 /** @}*/ // end of BaseSystem