Commit 218d2fcf authored by Ronan's avatar Ronan

feat(Object): add a MetaObjectBuilder (in progress)

parent 201dd37a
......@@ -144,7 +144,6 @@ 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
......@@ -248,7 +247,6 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
object/base-object.cpp
object/clonable-object.cpp
object/connection.cpp
object/internal/signal-emitter.cpp
object/object.cpp
object/property-container.cpp
sal/call-op.cpp
......
/*
* signal-emitter.cpp
* 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.
*/
#include "signal-emitter.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
namespace Private {
void activateSignal (Object *sender, int signalIndex, void **args) {
// TODO.
}
}
LINPHONE_END_NAMESPACE
/*
* 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,8 +25,28 @@
// =============================================================================
// -----------------------------------------------------------------------------
// Public macros API.
// -----------------------------------------------------------------------------
// Declare Smart Object implementation.
#define L_OBJECT_IMPL(CLASS) \
constexpr LinphonePrivate::MetaObject CLASS::metaObject = LinphonePrivate::MetaObjectBuilder::createMetaObject<CLASS>();
LINPHONE_BEGIN_NAMESPACE
class MetaObjectBuilder {
public:
template<typename T>
static constexpr MetaObject createMetaObject () {
// TODO.
return MetaObject();
}
private:
L_DISABLE_COPY(MetaObjectBuilder);
};
class ObjectPrivate : public BaseObjectPrivate {
protected:
inline const Object::Lock &getLock () const {
......
......@@ -55,6 +55,10 @@ const Object::Lock &Object::getLock () const {
// -----------------------------------------------------------------------------
void MetaObject::activateSignal (Object *sender, const MetaObject *metaObject, int signalIndex, void **args) {
// TODO.
}
#define CHECK_CONNECT_PARAM(PARAM) \
do { \
if (!PARAM) { \
......
......@@ -25,7 +25,6 @@
#include "base-object.h"
#include "connection.h"
#include "internal/signal-emitter.h"
#include "internal/slot-object.h"
#include "property-container.h"
......@@ -72,7 +71,7 @@
#define L_OBJECT(CLASS) \
public: \
typedef CLASS lType; \
using lBaseType = std::remove_reference< \
using lParentType = std::remove_reference< \
decltype(LinphonePrivate::Private::getParentObject(&lType::lParent)) \
>::type; \
private: \
......@@ -80,9 +79,6 @@
public: \
virtual void lParent () override {};
// Declare Smart Object implementation.
#define L_OBJECT_IMPL(CLASS)
// Declare one signal method.
#define L_SIGNAL(NAME, TYPES, ...) \
void NAME (L_APPLY_LIST(L_INTERNAL_SIGNAL_CONCAT_TYPE_ARG, TYPES, __VA_ARGS__)) { \
......@@ -112,6 +108,15 @@
LINPHONE_BEGIN_NAMESPACE
/*
* Meta data of one object.
* Gives a lot of info on one object.
*/
class LINPHONE_PUBLIC MetaObject {
public:
static void activateSignal (Object *sender, const MetaObject *metaObject, int signalIndex, void **args);
};
namespace Private {
// Compilation counter.
template<int N = 255>
......@@ -127,6 +132,18 @@ namespace Private {
static constexpr int value = 0;
};
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)... };
MetaObject::activateSignal(self, &Obj::metaObject, Index, argsPack);
}
};
template<typename T>
T &getParentObject (void (T::*)());
};
......
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