7 #ifndef __FWCOM_UTIL_WEAKCALL_HPP__ 8 #define __FWCOM_UTIL_WEAKCALL_HPP__ 10 #include "fwCom/exception/WorkerChanged.hpp" 12 #include <fwCore/exceptionmacros.hpp> 13 #include <fwCore/mt/types.hpp> 34 template<
typename T,
typename R >
38 WeakCall(
const std::shared_ptr< T const >& ptr, std::function< R() > f) :
42 SLM_TRACE(
"WeakCall object : " + ptr->getClassname() );
45 WeakCall(
const std::shared_ptr< T const >& ptr, std::function< R() > f,
46 const std::shared_ptr< ::fwThread::Worker >& m) :
51 SLM_TRACE(
"WeakCall object : " + ptr->getClassname() );
62 std::shared_ptr< T const > ptr(this->m_weakPtr.lock());
68 std::shared_ptr< T const > ptr(this->m_weakPtr);
73 std::shared_ptr< ::fwThread::Worker > worker = m_worker.lock();
75 if (worker && ptr->m_worker != worker)
81 this->m_weakPtr.reset();
83 return this->m_func();
87 mutable std::weak_ptr< T const > m_weakPtr;
88 std::function< R() > m_func;
89 mutable std::weak_ptr< ::fwThread::Worker > m_worker;
93 template <
typename T,
typename R >
100 template <
typename T,
typename R >
102 const std::shared_ptr< ::fwThread::Worker >& m)
Namespace containing fw4spl communication tools.
WeakCall< T, R > weakcall(const std::shared_ptr< T const > &ptr, std::function< R() > f)
Returns weak call from given object and function.
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
Weak functor class. Store a zero-arg-function and a weak pointer on an object. The WeakCall is callab...
#define SLM_TRACE(message)