33 #include <Pt/Callable.h>
34 #include <Pt/Connectable.h>
46 template <
typename R,
typename ClassT,
typename... As>
86 return (_object->*_method)(args...);
92 (_object->*_method)(args...);
103 _object = other._object;
104 _method = other._method;
112 return _object == other._object && _method == other._method;
124 template <
typename R,
typename ClassT,
typename... As>
149 _method.
object().onConnectionOpen(connection);
155 _method.
object().onConnectionClose(connection);
162 return other && _method == other->_method;
166 Method<R, ClassT, As...> _method;
174 template <
typename R,
typename BaseT,
typename ClassT,
typename... As>
177 return Method<R, ClassT, As...>(object, method);
185 template <
typename R,
typename BaseT,
typename ClassT,
typename... As>
188 return MethodSlot<R, ClassT, As...>(callable(
object, method));
Core module.
Definition: Allocator.h:33
Adapter for class methods.
Definition: Method.h:48
An interface for all callable entities.
Definition: Callable.h:48
R(ClassT::* MemFuncT)(As...)
The wrapped member function signature.
Definition: Method.h:52
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
MethodSlot(const Method< R, ClassT, As... > &method)
Constructs from callable.
Definition: Method.h:130
bool operator==(const Method &other) const
Returns true if both use the same object and function pointer.
Definition: Method.h:110
virtual const Callback * callable() const
Returns the callable converted to the type-erased Callback interface.
Definition: Method.h:141
Base type for various "slot" types.
Definition: Slot.h:92
Wraps Method objects so that they can act as Slots.
Definition: Method.h:126
ClassT & object()
Returns a reference to this object's wrapped ClassT object.
Definition: Method.h:64
virtual void onConnect(const Connection &connection)
Notifies of connects.
Definition: Method.h:147
virtual void onDisconnect(const Connection &connection)
Notifies of disconnects.
Definition: Method.h:153
MethodSlot< R, ClassT, As... > slot(ClassT &object, R(BaseT::*method)(As...))
Returns a slot object for the given object/member pair.
Definition: Method.h:186
Method(ClassT &object, MemFuncT method)
Wraps the given object/member pair.
Definition: Method.h:57
const ClassT & object() const
Returns a const reference to the wrapped ClassT object.
Definition: Method.h:71
const MemFuncT & method() const
Returns a reference to the wrapped member function.
Definition: Method.h:78
virtual bool equals(const Slot &slot) const
Returns true if two slots are equal in value.
Definition: Method.h:159
Endpoint of a signal/slot connection.
Definition: Slot.h:55
void invoke(As... args) const
Invokes the invokable entity with the given arguments.
Definition: Method.h:90
R call(As... args) const
Calls the callable entity and returns its result.
Definition: Method.h:84
Slot * clone() const
Clone this object with new.
Definition: Method.h:135
Method< R, ClassT, As... > callable(ClassT &object, R(BaseT::*method)(As...))
Returns a Method object for the given object/method pair.
Definition: Method.h:175
Represents a connection between a Signal/Delegate and a slot.
Definition: Connection.h:96