34 #include <Pt/Callable.h>
56 template <
typename R,
typename A1 =
Void,
typename A2 =
Void,
57 typename A3 =
Void,
typename A4 =
Void,
58 typename A5 =
Void,
typename A6 =
Void,
59 typename A7 =
Void,
typename A8 =
Void,
60 typename A9 =
Void,
typename A10 =
Void >
72 BindAdaptorBase(
const Slot& s,
const T& a)
77 BindAdaptorBase(
const BindAdaptorBase& c)
78 : _slot( c._slot->clone() )
85 BindAdaptorBase& operator=(
const BindAdaptorBase& b)
90 Slot* s = b.slot().clone();
101 const Slot& slot()
const
113 template <
typename R,
typename A1,
114 typename A2 = Void,
typename A3 = Void,
116 class BindAdaptor :
public Callable<R, A1, A2, A3>
117 ,
public BindAdaptorBase<A4>
120 typedef BasicSlot<R, A1, A2, A3> SlotBase;
123 BindAdaptor(
const BasicSlot<R, A1, A2, A3, A4>& slot,
const A4& a)
124 : BindAdaptorBase<A4>(slot, a)
127 virtual Callable<R, A1, A2, A3>* clone()
const
128 {
return new BindAdaptor(*
this); }
130 virtual R
operator()(A1 a1, A2 a2, A3 a3)
const
132 const Callable<R, A1, A2, A3, A4>* cb =
133 static_cast< const Callable<R, A1, A2, A3, A4>*
>( this->slot().callable() );
135 return cb->call( a1, a2, a3, this->arg() );
140 template <
typename R,
typename A1,
141 typename A2,
typename A3>
142 class BindAdaptor<R, A1, A2, A3, Void> :
public Callable<R, A1, A2>
143 ,
public BindAdaptorBase<A3>
146 typedef BasicSlot<R, A1, A2> SlotBase;
149 BindAdaptor(
const BasicSlot<R, A1, A2, A3>& slot,
const A3& a)
150 : BindAdaptorBase<A3>(slot, a)
153 virtual Callable<R, A1, A2>* clone()
const
154 {
return new BindAdaptor(*
this); }
158 const Callable<R, A1, A2, A3>* cb =
159 static_cast< const Callable<R, A1, A2, A3>*
>( this->slot().callable() );
161 return cb->call( a1, a2, this->arg() );
167 template <
typename R,
typename A1,
typename A2>
168 class BindAdaptor<R, A1, A2, Void, Void> :
public Callable<R, A1>
169 ,
public BindAdaptorBase<A2>
172 typedef BasicSlot<R, A1> SlotBase;
175 BindAdaptor(
const BasicSlot<R, A1, A2>& slot,
const A2& a)
176 : BindAdaptorBase<A2>(slot, a)
179 virtual Callable<R, A1>* clone()
const
180 {
return new BindAdaptor(*
this); }
184 const Callable<R, A1, A2>* cb =
185 static_cast< const Callable<R, A1, A2>*
>( this->slot().callable() );
187 return cb->call( a1, this->arg() );
192 template <
typename R,
typename A1>
193 class BindAdaptor<R, A1, Void, Void, Void> :
public Callable<R>
194 ,
public BindAdaptorBase<A1>
197 typedef BasicSlot<R> SlotBase;
200 BindAdaptor(
const BasicSlot<R, A1>& slot,
const A1& a)
201 : BindAdaptorBase<A1>(slot, a)
204 virtual Callable<R>* clone()
const
205 {
return new BindAdaptor(*
this); }
209 const Callable<R, A1>* cb =
210 static_cast< const Callable<R, A1>*
>( this->slot().callable() );
212 return cb->call( this->arg() );
217 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4>
218 class BoundSlot :
public BindAdaptor<R, A1, A2, A3, A4>::SlotBase
221 template <
typename T>
222 BoundSlot(
const BasicSlot<R, A1, A2, A3, A4>& slot,
const T& a)
228 return new BoundSlot(*
this);
231 virtual const void* callable()
const
236 virtual void onConnect(
const Connection& c)
238 _adaptor.slot().onConnect(c);
241 virtual void onDisconnect(
const Connection& c)
243 _adaptor.slot().onDisconnect(c);
246 virtual bool equals(
const Slot& slot)
const
248 return _adaptor.slot().equals(slot);
252 BindAdaptor<R, A1, A2, A3, A4> _adaptor;
256 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename T>
257 BoundSlot<R, A1, A2, A3, A4> slot(
const BasicSlot<R, A1, A2, A3, A4>& slot,
const T& a)
259 return BoundSlot<R, A1, A2, A3, A4>(slot, a);
virtual Slot * clone() const =0
Clone this object with new.
Endpoint of a signal/slot connection.
Definition: Slot.h:21
Represents a connection between a Signal/Delegate and a slot.
Definition: Connection.h:90
virtual Slot * clone() const =0
Clone this object with new.
virtual ~Slot()
Destructor.
Definition: Slot.h:25
virtual bool equals(const Slot &slot) const =0
Returns true if two slots are equal in value.
virtual R operator()(A1) const =0
Call the callable entity.
virtual void onConnect(const Connection &c)=0
Notifies of connects.
Base type for various "slot" types.
Definition: Slot.h:47
Void type.
Definition: Void.h:43
virtual const void * callable() const =0
Returns a pointer to the contained callable.
ConstMethodSlot< R, C, ARGS > slot(C &obj, R(BaseT::*memFunc)(ARGS) const )
Returns a slot object for the given object/member pair.
virtual void onDisconnect(const Connection &c)=0
Notifies of disconnects.