add lambda connection
This commit is contained in:
@@ -145,6 +145,8 @@ GenericMFPtr *Object::findSlotImpl(const char *name) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Object::Updated() { ULIB_SIGNAL_EMIT(Object::Updated); }
|
||||
|
||||
// std::ostream &
|
||||
// operator << (std::ostream &os, uLib::Object &ob)
|
||||
// {
|
||||
|
||||
@@ -97,6 +97,9 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SIGNALS //
|
||||
|
||||
signals:
|
||||
virtual void Updated();
|
||||
|
||||
// Qt4 style connector //
|
||||
static bool connect(const Object *ob1, const char *signal_name,
|
||||
const Object *receiver, const char *slot_name) {
|
||||
@@ -121,6 +124,25 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Lambda/Function object connector //
|
||||
template <typename Func1, typename SlotT>
|
||||
static bool connect(typename FunctionPointer<Func1>::Object *sender,
|
||||
Func1 sigf, SlotT slof) {
|
||||
SignalBase *sigb = sender->findOrAddSignal(sigf);
|
||||
typedef typename FunctionPointer<Func1>::SignalSignature SigSignature;
|
||||
typedef typename Signal<SigSignature>::type SigT;
|
||||
reinterpret_cast<SigT *>(sigb)->connect(slof);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Func1, typename Func2>
|
||||
static bool
|
||||
disconnect(typename FunctionPointer<Func1>::Object *sender, Func1 sigf,
|
||||
typename FunctionPointer<Func2>::Object *receiver, Func2 slof) {
|
||||
// TODO: implement actual disconnect in Signal.h //
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename FuncT>
|
||||
static inline bool connect(SignalBase *sigb, FuncT slof, Object *receiver) {
|
||||
ConnectSignal<typename FunctionPointer<FuncT>::SignalSignature>(sigb, slof,
|
||||
|
||||
Reference in New Issue
Block a user