18 #ifndef GAZEBO_COMMON_WEAKBIND_HH_ 19 #define GAZEBO_COMMON_WEAKBIND_HH_ 21 #include <boost/shared_ptr.hpp> 22 #include <boost/bind.hpp> 32 template <
typename Func,
typename T>
35 public:
using WeakPtr = boost::weak_ptr<T>;
54 public:
template <
typename... Args>
auto operator()(Args&&... _args)
55 ->
typename std::enable_if<
57 decltype(this->func(std::forward<Args>(_args)...))
59 decltype(this->func(std::forward<Args>(_args)...))
62 auto ptrLock = this->ptr.lock();
65 return this->func(std::forward<Args>(_args)...);
74 public:
template <
typename... Args>
auto operator()(Args&&... _args)
75 ->
typename std::enable_if<
77 decltype(this->func(std::forward<Args>(_args)...))
82 auto ptrLock = this->ptr.lock();
85 this->func(std::forward<Args>(_args)...);
90 template <
typename Func,
typename T>
109 template <
typename T,
typename Func,
typename... Args>
110 auto weakBind(Func _func, boost::shared_ptr<T> _ptr, Args... _args)
111 #if __cplusplus < 201402L 113 boost::bind(_func, _ptr.get(), _args...),
114 boost::weak_ptr<T>(_ptr)))
118 boost::bind(_func, _ptr.get(), _args...),
119 boost::weak_ptr<T>(_ptr));
auto weakBind(Func _func, boost::shared_ptr< T > _ptr, Args... _args) -> decltype(details::makeWeakBinder(boost::bind(_func, _ptr.get(), _args...), boost::weak_ptr< T >(_ptr)))
Definition: WeakBind.hh:110
Forward declarations for the common classes.
Definition: Animation.hh:26
WeakBinder< Func, T > makeWeakBinder(Func func, boost::weak_ptr< T > ptr)
Definition: WeakBind.hh:91
Function object wrapper used by common::weakBind.
Definition: WeakBind.hh:33
auto operator()(Args &&... _args) -> typename std::enable_if< std::is_void< decltype(this->func(std::forward< Args >(_args)...)) >::value, void >::type
Return void version.
Definition: WeakBind.hh:74
auto operator()(Args &&... _args) -> typename std::enable_if< !std::is_void< decltype(this->func(std::forward< Args >(_args)...)) >::value, decltype(this->func(std::forward< Args >(_args)...)) >::type
Return non-void version.
Definition: WeakBind.hh:54
boost::weak_ptr< T > WeakPtr
Definition: WeakBind.hh:35
WeakBinder(Func _func, WeakPtr _ptr)
Constructor.
Definition: WeakBind.hh:48