fw4spl
RecursiveLock.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "fwDataCamp/config.hpp"
10 
11 #include <fwCamp/camp/ExtendedClassVisitor.hpp>
12 
13 #include <fwCore/macros.hpp>
14 #include <fwCore/mt/types.hpp>
15 
16 #include <vector>
17 
18 namespace fwData
19 {
20 class Object;
21 
22 namespace mt
23 {
24 class ObjectReadLock;
25 }
26 }
27 
28 namespace fwDataCamp
29 {
30 
31 namespace visitor
32 {
33 
37 class FWDATACAMP_CLASS_API RecursiveLock : public ::camp::ExtendedClassVisitor
38 {
39 
40 public:
41 
45  typedef std::vector< SPTR(::fwCore::mt::ReadLock) > LockVectType;
46 
55  FWDATACAMP_API RecursiveLock( CSPTR(::fwData::Object)object,
56  SPTR(LockVectType)locks = SPTR(LockVectType)(new LockVectType()));
57 
58  FWDATACAMP_API virtual ~RecursiveLock();
59 
63  FWDATACAMP_API void visit(const camp::SimpleProperty& property);
64  FWDATACAMP_API void visit(const camp::EnumProperty& property);
65  FWDATACAMP_API void visit(const camp::UserProperty& property);
66  FWDATACAMP_API void visit(const camp::ArrayProperty& property);
67  FWDATACAMP_API void visit(const camp::Function& function);
68  FWDATACAMP_API virtual void visit(const camp::MapProperty& property);
71 private:
72 
74  void lock();
75 
77  CSPTR(::fwData::Object) m_object;
78 
80  SPTR(LockVectType) m_locks;
81 
83  ::camp::UserObject m_campObj;
84 
85 };
86 
87 } // namespace visitor
88 
89 } // namespace fwDataCamp
#define SPTR(_cls_)
#define CSPTR(_cls_)
This file defines fwCore base macros.
This namespace contains data object descriptions used for introspection.
std::vector< std::shared_ptr< ::fwCore::mt::ReadLock > > LockVectType
Container definition dedicated to object locks storage.
This class is an helper to lock an object and all its children recursively.
Base class for each data object.
Contains the representation of the data objects used in the framework.