Commit 5156b2c0 authored by Ronan's avatar Ronan

feat(Object): add internal SignalEmitter object

parent 308d49dc
......@@ -144,6 +144,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
object/internal/function-call.h
object/internal/function-pointer.h
object/internal/list.h
object/internal/signal-emitter.h
object/internal/slot-object.h
object/object-head-p.h
object/object-head.h
......
/*
* signal-emitter.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_SIGNAL_EMITTER_H_
#define _L_SIGNAL_EMITTER_H_
#include "linphone/utils/general.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
namespace Private {
void activateSignal (Object *sender, int signalIndex, void **args);
template<typename Func, int Index>
struct SignalEmitter {};
template<typename Obj, typename... Args, int Index>
struct SignalEmitter<void (Obj::*)(Args...), Index> {
Obj *self;
inline void operator () (Args... args) {
void *argsPack[] = { (&args)... };
activateSignal(self, Index, argsPack);
}
};
}
LINPHONE_END_NAMESPACE
#endif // ifndef _L_SIGNAL_EMITTER_H_
......@@ -25,6 +25,7 @@
#include "base-object.h"
#include "connection.h"
#include "internal/signal-emitter.h"
#include "internal/slot-object.h"
#include "property-container.h"
......@@ -44,7 +45,7 @@
#define L_SIGNAL(NAME, TYPES, ...) void NAME (L_APPLY_LIST(L_SIGNAL_CONCAT_TYPE_ARG, TYPES, __VA_ARGS__)) { \
typedef std::remove_reference<decltype(*this)>::type ClassType; \
typedef decltype(L_CALL(L_RESOLVE_OVERLOAD, TYPES)(&ClassType::NAME)) SignalType; \
SignalType sig; (void)sig; \
LinphonePrivate::Private::SignalEmitter<SignalType, __LINE__>{this}(__VA_ARGS__); \
}
#define L_CHECK_CONNECT_TYPES(SIGNAL_TYPE, SLOT_TYPE) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment