35#include <Pt/Callable.h>
46 BindAdaptorBase(
const Slot& s,
const T& a)
51 BindAdaptorBase(
const BindAdaptorBase& c)
52 : _slot( c._slot->clone() )
59 BindAdaptorBase& operator=(
const BindAdaptorBase& b)
64 Slot* s = b.slot().clone();
77 const Slot&
slot()
const
92namespace SigSlotDetail {
94template <
typename R,
typename Tuple,
typename Indices>
97template <
typename R,
typename Tuple, std::size_t... Is>
98class BindAdaptor<R, Tuple, std::index_sequence<Is...>>
99:
public Callable<R, typename std::tuple_element<Is, Tuple>::type...>
100,
public BindAdaptorBase<
101 typename std::tuple_element<std::tuple_size<Tuple>::value - 1, Tuple>::type>
104 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - 1, Tuple>::type BoundT;
105 typedef BasicSlot<R, typename std::tuple_element<Is, Tuple>::type...> SlotBase;
106 typedef BasicSlot<R, typename std::tuple_element<Is, Tuple>::type..., BoundT> FullSlotBase;
107 typedef Callable<R, typename std::tuple_element<Is, Tuple>::type...> CallableBase;
108 typedef Callable<R, typename std::tuple_element<Is, Tuple>::type..., BoundT> FullCallable;
111 BindAdaptor(
const FullSlotBase&
slot,
const BoundT& arg)
112 : BindAdaptorBase<BoundT>(
slot, arg)
115 CallableBase* clone()
const
117 return new BindAdaptor(*
this);
121 R call(
typename std::tuple_element<Is, Tuple>::type... args)
const
124 static_cast<const FullCallable*
>( this->
slot().callable() );
129 void invoke(
typename std::tuple_element<Is, Tuple>::type... args)
const
132 static_cast<const FullCallable*
>( this->
slot().callable() );
146template <
typename R,
typename Tuple,
typename Indices>
148:
public SigSlotDetail::BindAdaptor<R, Tuple, Indices>::SlotBase
150 typedef SigSlotDetail::BindAdaptor<R, Tuple, Indices> AdaptorT;
153 template <
typename T>
154 BoundSlot(
const typename AdaptorT::FullSlotBase&
slot,
const T& arg)
155 : _adaptor(
slot, arg)
160 return new BoundSlot(*
this);
164 virtual const Callback* callable()
const
169 virtual void onConnect(
const Connection& connection)
171 _adaptor.slot().onConnect(connection);
174 virtual void onDisconnect(
const Connection& connection)
176 _adaptor.slot().onDisconnect(connection);
179 virtual bool equals(
const Slot&
slot)
const
181 return _adaptor.slot().equals(
slot);
188namespace SigSlotDetail {
190template <
typename R,
typename Tuple>
191struct BoundSlotTraits;
193template <
typename R,
typename A,
typename... As>
194struct BoundSlotTraits<R, std::tuple<A, As...>>
197 std::tuple<A, As...>,
198 std::make_index_sequence<
sizeof...(As)>> Type;
210template <
typename R,
typename... As,
typename T>
211typename SigSlotDetail::BoundSlotTraits<R, std::tuple<As...>>::Type
214 typedef typename SigSlotDetail::BoundSlotTraits<R, std::tuple<As...>>::Type BoundSlotT;
215 return BoundSlotT(
slot, arg);
Base type for various "slot" types.
Definition Slot.h:92
Slot produced by binding a final argument to another slot.
Definition SlotBind.h:149
SigSlotDetail::BoundSlotTraits< R, std::tuple< As... > >::Type slot(const BasicSlot< R, As... > &slot, const T &arg)
Binds the final argument of a slot to a copied value.
Definition SlotBind.h:212
ConstMethod< R, ClassT, As... > callable(ClassT &object, R(BaseT::*method)(As...) const)
Returns a ConstMethod object for the given object/method pair.
Definition ConstMethod.h:161
Represents a connection between a Signal/Delegate and a slot.
Definition Connection.h:96
R call(As... args) const
Calls the callable entity and returns its result.
Definition ConstMethod.h:77
Endpoint of a signal/slot connection.
Definition Slot.h:55
ConstMethodSlot< R, ClassT, As... > slot(ClassT &object, R(BaseT::*method)(As...) const)
Returns a slot object for the given object/member pair.
Definition ConstMethod.h:172
Core module.
Definition Allocator.h:33