Commit 201dd37a authored by Wescoeur's avatar Wescoeur Committed by Ronan

feat(Object): add a little hack to get parent type of class

parent 3d846309
......@@ -41,6 +41,8 @@ class LINPHONE_PUBLIC BaseObject {
public:
virtual ~BaseObject ();
virtual void lParent () {};
protected:
explicit BaseObject (BaseObjectPrivate &p);
......
......@@ -70,14 +70,15 @@
// Declare one Smart Object with Signals.
#define L_OBJECT(CLASS) \
private: \
public: \
typedef CLASS lType; \
static constexpr const char *lName = #CLASS; \
using lBaseType = std::remove_reference< \
decltype(LinphonePrivate::Private::getParentObject(&lType::lParent)) \
>::type; \
private: \
friend constexpr std::tuple<> lMetaSignals (LinphonePrivate::Private::MetaObjectCounter<0>, lType **) { return {}; } \
public: \
virtual const char *getName () { \
return lName; \
}
virtual void lParent () override {};
// Declare Smart Object implementation.
#define L_OBJECT_IMPL(CLASS)
......@@ -125,6 +126,9 @@ namespace Private {
struct MetaObjectCounter<0> {
static constexpr int value = 0;
};
template<typename T>
T &getParentObject (void (T::*)());
};
/*
......@@ -136,6 +140,8 @@ class LINPHONE_PUBLIC Object :
public std::enable_shared_from_this<Object>,
public BaseObject,
public PropertyContainer {
L_OBJECT(Object);
public:
typedef std::recursive_mutex Lock;
......
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