7 #include "fwDataCamp/visitor/RecursiveLock.hpp" 9 #include "fwDataCamp/exception/NullPointer.hpp" 10 #include "fwDataCamp/exception/ObjectNotFound.hpp" 12 #include <fwCore/mt/types.hpp> 14 #include <fwData/camp/mapper.hpp> 15 #include <fwData/Object.hpp> 17 #include <fwMemory/BufferObject.hpp> 36 void operator()(camp::NoType value)
42 void operator()(
bool value)
48 void operator()(
long value)
54 void operator()(
double value)
60 void operator()(
const std::string& value)
66 void operator()(
const camp::EnumObject& value)
72 void operator()(
const camp::UserObject& value)
74 const camp::Class& metaclass = value.getClass();
75 if ( value.pointer() )
77 OSLM_DEBUG(
"visit class= '" << metaclass.name() <<
"' ( classname = '"<< value.call(
"classname") <<
"' )" );
78 if( metaclass.hasFunction(
"is_a") )
80 if( value.call(
"is_a", ::camp::Args(
"::fwData::Object")).to<
bool>() )
83 ::fwData::Object::sptr obj = ptr->getSptr();
86 else if( value.call(
"is_a", ::camp::Args(
"::fwMemory::BufferObject")).to<
bool>() )
89 ::fwMemory::BufferObject::sptr bo = ptr->getSptr();
92 m_locks->push_back(lock);
107 m_locks->push_back(lock);
108 m_campObj = camp::UserObject( *
object );
114 RecursiveLock::~RecursiveLock()
120 void RecursiveLock::visit(
const camp::SimpleProperty& property)
126 void RecursiveLock::visit(
const camp::EnumProperty& property)
134 const std::string name( property.name() );
135 const size_t size =
property.getSize( m_campObj );
137 std::pair< ::camp::Value, ::camp::Value > value;
139 ::camp::Value second;
141 for (
size_t var = 0; var < size; ++var)
143 value =
property.getElement(m_campObj, var);
146 second = value.second;
149 first.type() == ::camp::stringType ||
150 first.type() == ::camp::intType ||
151 first.type() == ::camp::realType );
153 if ( second.type() == ::camp::userType )
156 second.visit( visitor );
163 void RecursiveLock::visit(
const camp::ArrayProperty& property)
165 const std::string name( property.name() );
166 const size_t size =
property.size( m_campObj );
170 for (
size_t var = 0; var < size; ++var)
172 value =
property.get(m_campObj, var);
174 if ( value.type() == ::camp::userType )
177 value.visit( visitor );
184 void RecursiveLock::visit(
const camp::UserProperty& property)
187 const std::string name( property.name() );
189 ::camp::Value elemValue =
property.get( m_campObj );
191 elemValue.visit( visitor );
196 void RecursiveLock::visit(
const camp::Function&
function)
202 void RecursiveLock::lock()
204 const camp::Class& camClass = ::camp::classByName( m_object->getClassname() );
205 camClass.visit( *
this );
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWDATACAMP_API RecursiveLock(std::shared_ptr< const ::fwData::Object >object, std::shared_ptr< LockVectType >locks=std::shared_ptr< LockVectType >(new LockVectType()))
Constructor. Creates a recursive lock onto the given object and recursively locks it...
This namespace contains data object descriptions used for introspection.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
std::vector< std::shared_ptr< ::fwCore::mt::ReadLock > > LockVectType
Container definition dedicated to object locks storage.
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
This class is an helper to lock an object and all its children recursively.
Base class for each data object.
Define Base class for FW4SPL buffers.
#define OSLM_DEBUG(message)