fw4spl
ObjectReadToWriteLock.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWDATA_MT_OBJECTREADTOWRITELOCK_HPP__
8 #define __FWDATA_MT_OBJECTREADTOWRITELOCK_HPP__
9 
10 #include "fwData/Object.hpp"
11 #include "fwData/config.hpp"
12 
13 #include <fwCore/mt/types.hpp>
14 
15 namespace fwData
16 {
17 namespace mt
18 {
19 
23 class FWDATA_CLASS_API ObjectReadToWriteLock
24 {
25 
26 public:
27 
32  FWDATA_API ObjectReadToWriteLock( ::fwData::Object::sptr obj, bool lock = true );
33 
35  FWDATA_API ~ObjectReadToWriteLock();
36 
38  FWDATA_API void lock();
39 
41  FWDATA_API void unlock();
42 
44  FWDATA_API void upgrade();
45 
47  FWDATA_API void downgrade();
48 
49 private:
50 
53  SPTR(::fwCore::mt::UpgradeToWriteLock) m_upgradedLock;
54 };
55 
56 } // mt
57 } // fwData
58 
59 #endif // __FWDATA_MT_OBJECTREADTOWRITELOCK_HPP__
#define SPTR(_cls_)
::boost::upgrade_lock< ReadWriteMutex > ReadToWriteLock
Defines an upgradable lock type for read/write mutex.
::boost::upgrade_to_unique_lock< ReadWriteMutex > UpgradeToWriteLock
Defines a write lock upgraded from ReadToWriteLock.
A helper to lock object on upgradable mode.
Contains the representation of the data objects used in the framework.