mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 09:09:21 +00:00
feat(Core): provide a low-level BaseObject
This commit is contained in:
parent
d160e5ab02
commit
2941e64e3e
37 changed files with 443 additions and 264 deletions
|
|
@ -29,7 +29,6 @@
|
|||
#endif // ifdef __cplusplus
|
||||
|
||||
LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_new (void);
|
||||
LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_clone (const LinphoneEventLog *event_log);
|
||||
LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_ref (LinphoneEventLog *event_log);
|
||||
LINPHONE_PUBLIC LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_log);
|
||||
|
||||
|
|
@ -38,7 +37,6 @@ LINPHONE_PUBLIC LinphoneCallEvent *linphone_call_event_new (
|
|||
time_t time,
|
||||
LinphoneCall *call
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneCallEvent *linphone_call_event_clone (const LinphoneCallEvent *call_event);
|
||||
LINPHONE_PUBLIC LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new (
|
||||
|
|
@ -46,7 +44,6 @@ LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new (
|
|||
time_t time,
|
||||
const LinphoneAddress *address
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_clone (const LinphoneConferenceEvent *conference_event);
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_address (const LinphoneConferenceEvent *conference_event);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new (
|
||||
|
|
@ -55,9 +52,6 @@ LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_particip
|
|||
const LinphoneAddress *conferenceAddress,
|
||||
const LinphoneAddress *participantAddress
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_clone (
|
||||
const LinphoneConferenceParticipantEvent *conference_participant_event
|
||||
);
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get_participant_address (
|
||||
const LinphoneConferenceParticipantEvent *conference_participant_event
|
||||
);
|
||||
|
|
@ -66,9 +60,6 @@ LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_new (
|
|||
LinphoneChatMessage *chat_message,
|
||||
time_t time
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_clone (
|
||||
const LinphoneChatMessageEvent *chat_message_event
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_message_event_get_chat_message (
|
||||
const LinphoneChatMessageEvent *chat_message_event
|
||||
);
|
||||
|
|
|
|||
|
|
@ -82,27 +82,42 @@ void l_assert (const char *condition, const char *file, int line);
|
|||
#define L_UNLIKELY(EXPRESSION) EXPRESSION
|
||||
#endif
|
||||
|
||||
class BaseObject;
|
||||
class BaseObjectPrivate;
|
||||
class ClonableObject;
|
||||
class ClonableObjectPrivate;
|
||||
class Object;
|
||||
class ObjectPrivate;
|
||||
|
||||
#define L_INTERNAL_DECLARE_PRIVATE(CLASS) \
|
||||
inline CLASS ## Private *getPrivate() { \
|
||||
return reinterpret_cast<CLASS ## Private *>(mPrivate); \
|
||||
} \
|
||||
inline const CLASS ## Private *getPrivate() const { \
|
||||
return reinterpret_cast<const CLASS ## Private *>(mPrivate); \
|
||||
} \
|
||||
friend class CLASS ## Private; \
|
||||
friend class Wrapper;
|
||||
#define L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS) \
|
||||
static_assert( \
|
||||
!(std::is_base_of<BaseObject, CLASS>::value && std::is_base_of<ClonableObject, CLASS>::value), \
|
||||
"Multiple inheritance between BaseObject and ClonableObject is not allowed." \
|
||||
);
|
||||
|
||||
#define L_INTERNAL_DECLARE_PRIVATE_T(CLASS, PARENT_TYPE) \
|
||||
inline CLASS ## Private *getPrivate() { \
|
||||
return reinterpret_cast<CLASS ## Private *>(PARENT_TYPE::mPrivate); \
|
||||
#define L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS) \
|
||||
std::conditional< \
|
||||
std::is_base_of<BaseObject, CLASS>::value, \
|
||||
BaseObject, \
|
||||
std::conditional< \
|
||||
std::is_base_of<ClonableObject, CLASS>::value, \
|
||||
ClonableObject, \
|
||||
CLASS \
|
||||
>::type \
|
||||
>::type
|
||||
|
||||
#define L_INTERNAL_DECLARE_PRIVATE(CLASS) \
|
||||
inline CLASS ## Private *getPrivate () { \
|
||||
L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS); \
|
||||
return reinterpret_cast<CLASS ## Private *>( \
|
||||
L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS)::mPrivate \
|
||||
); \
|
||||
} \
|
||||
inline const CLASS ## Private *getPrivate() const { \
|
||||
return reinterpret_cast<const CLASS ## Private *>(PARENT_TYPE::mPrivate); \
|
||||
inline const CLASS ## Private *getPrivate () const { \
|
||||
L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS); \
|
||||
return reinterpret_cast<const CLASS ## Private *>( \
|
||||
L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS)::mPrivate \
|
||||
); \
|
||||
} \
|
||||
friend class CLASS ## Private; \
|
||||
friend class Wrapper;
|
||||
|
|
@ -111,17 +126,13 @@ class ObjectPrivate;
|
|||
// Gives a control to C Wrapper.
|
||||
#ifndef LINPHONE_TESTER
|
||||
#define L_DECLARE_PRIVATE(CLASS) L_INTERNAL_DECLARE_PRIVATE(CLASS)
|
||||
#define L_DECLARE_PRIVATE_T(CLASS, PARENT_TYPE) L_INTERNAL_DECLARE_PRIVATE_T(CLASS, PARENT_TYPE)
|
||||
#else
|
||||
#define L_DECLARE_PRIVATE(CLASS) \
|
||||
L_INTERNAL_DECLARE_PRIVATE(CLASS) \
|
||||
friend class Tester;
|
||||
#define L_DECLARE_PRIVATE_T(CLASS, PARENT_TYPE) \
|
||||
L_INTERNAL_DECLARE_PRIVATE_T(CLASS, PARENT_TYPE) \
|
||||
friend class Tester;
|
||||
#endif
|
||||
|
||||
// Generic public helper. (Neither ClonableObject nor Object.)
|
||||
// Generic public helper. (Neither ClonableObject.)
|
||||
// `void *` is used to avoid downcasting.
|
||||
template<typename T>
|
||||
constexpr T *getPublicHelper (void *object, const void *) {
|
||||
|
|
@ -135,11 +146,6 @@ inline T *getPublicHelper (const U *map, const ClonableObjectPrivate *context) {
|
|||
return static_cast<T *>(it->second);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T *getPublicHelper (Object *object, const ObjectPrivate *) {
|
||||
return static_cast<T *>(object);
|
||||
}
|
||||
|
||||
#define L_DECLARE_PUBLIC(CLASS) \
|
||||
inline CLASS *getPublic () { \
|
||||
L_ASSERT(mPublic); \
|
||||
|
|
|
|||
|
|
@ -111,8 +111,12 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
nat/ice-agent.h
|
||||
nat/stun-client.h
|
||||
object/app-data-container.h
|
||||
object/base-object-p.h
|
||||
object/base-object.h
|
||||
object/clonable-object-p.h
|
||||
object/clonable-object.h
|
||||
object/object-head-p.h
|
||||
object/object-head.h
|
||||
object/object-p.h
|
||||
object/object.h
|
||||
object/property-container.h
|
||||
|
|
@ -191,6 +195,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
nat/ice-agent.cpp
|
||||
nat/stun-client.cpp
|
||||
object/app-data-container.cpp
|
||||
object/base-object.cpp
|
||||
object/clonable-object.cpp
|
||||
object/object.cpp
|
||||
object/property-container.cpp
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(Address);
|
||||
L_DECLARE_C_CLONABLE_OBJECT_IMPL(Address);
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(CallParams)
|
||||
L_DECLARE_C_CLONABLE_OBJECT_IMPL(CallParams)
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(EventLog);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(CallEvent);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(ConferenceEvent);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(ConferenceParticipantEvent);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(ConferenceParticipantDeviceEvent);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(ConferenceSubjectEvent);
|
||||
L_DECLARE_C_CLONABLE_STRUCT_IMPL(ChatMessageEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(EventLog);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(CallEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantDeviceEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceSubjectEvent);
|
||||
L_DECLARE_C_BASE_OBJECT_IMPL(ChatMessageEvent);
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// MetaInfo.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
template<typename CppType>
|
||||
struct CppTypeMetaInfo {
|
||||
enum {
|
||||
|
|
@ -60,22 +64,27 @@ struct CTypeMetaInfo {
|
|||
|
||||
class Wrapper {
|
||||
private:
|
||||
// ---------------------------------------------------------------------------
|
||||
// IsCppObject traits.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<typename CppType>
|
||||
struct IsCppObject {
|
||||
enum {
|
||||
value = std::is_base_of<Object, CppType>::value || std::is_base_of<ClonableObject, CppType>::value
|
||||
value = std::is_base_of<BaseObject, CppType>::value || std::is_base_of<ClonableObject, CppType>::value
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CppPrivateType>
|
||||
struct IsPrivateCppObject {
|
||||
enum {
|
||||
value = std::is_base_of<ObjectPrivate, CppPrivateType>::value || std::is_base_of<ClonableObjectPrivate, CppPrivateType>::value
|
||||
value = std::is_base_of<BaseObjectPrivate, CppPrivateType>::value ||
|
||||
std::is_base_of<ClonableObjectPrivate, CppPrivateType>::value
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CppType>
|
||||
struct IsDefinedCppObject {
|
||||
struct IsRegisteredCppObject {
|
||||
enum {
|
||||
value = CppTypeMetaInfo<CppType>::defined && (
|
||||
!CppTypeMetaInfo<CppType>::isSubtype ||
|
||||
|
|
@ -84,30 +93,70 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// IsDefined traits.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<typename CppType>
|
||||
struct IsDefinedNotClonableCppObject {
|
||||
struct IsDefinedBaseCppObject {
|
||||
enum {
|
||||
value = IsDefinedCppObject<CppType>::value && std::is_base_of<Object, CppType>::value
|
||||
value = IsRegisteredCppObject<CppType>::value &&
|
||||
std::is_base_of<BaseObject, CppType>::value &&
|
||||
!std::is_base_of<Object, CppType>::value
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CppType>
|
||||
struct IsDefinedCppObject {
|
||||
enum {
|
||||
value = IsRegisteredCppObject<CppType>::value && std::is_base_of<Object, CppType>::value
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CppType>
|
||||
struct IsDefinedClonableCppObject {
|
||||
enum {
|
||||
value = IsDefinedCppObject<CppType>::value && std::is_base_of<ClonableObject, CppType>::value
|
||||
value = IsRegisteredCppObject<CppType>::value && std::is_base_of<ClonableObject, CppType>::value
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CType>
|
||||
struct WrappedObject {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Wrapped Objects.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<typename CppType>
|
||||
struct WrappedBaseObject {
|
||||
belle_sip_object_t base;
|
||||
std::shared_ptr<CType> cppPtr;
|
||||
CppType *cppPtr;
|
||||
};
|
||||
|
||||
template<typename CType>
|
||||
template<typename CppType>
|
||||
struct WrappedObject {
|
||||
belle_sip_object_t base;
|
||||
std::shared_ptr<CppType> cppPtr;
|
||||
};
|
||||
|
||||
template<typename CppType>
|
||||
struct WrappedClonableObject {
|
||||
belle_sip_object_t base;
|
||||
CType *cppPtr;
|
||||
CppType *cppPtr;
|
||||
};
|
||||
|
||||
template<typename CppType>
|
||||
struct WrappedObjectResolver {
|
||||
typedef typename std::conditional<
|
||||
IsDefinedBaseCppObject<CppType>::value,
|
||||
WrappedBaseObject<CppType>,
|
||||
typename std::conditional<
|
||||
IsDefinedCppObject<CppType>::value,
|
||||
WrappedObject<CppType>,
|
||||
typename std::conditional<
|
||||
IsDefinedClonableCppObject<CppType>::value,
|
||||
WrappedClonableObject<CppType>,
|
||||
void
|
||||
>::type
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -162,7 +211,7 @@ public:
|
|||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static L_INTERNAL_WRAPPER_CONSTEXPR std::shared_ptr<CppType> getCppPtrFromC (CType *cObject) {
|
||||
#ifdef DEBUG
|
||||
|
|
@ -186,27 +235,29 @@ public:
|
|||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static L_INTERNAL_WRAPPER_CONSTEXPR std::shared_ptr<const CppType> getCppPtrFromC (const CType *cObject) {
|
||||
#ifdef DEBUG
|
||||
return getCppPtrFromC<CType, CppType>(const_cast<CType *>(cObject));
|
||||
#else
|
||||
return reinterpret_cast<const WrappedObject<CppType> *>(cObject)->cppPtr;
|
||||
return reinterpret_cast<const typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<
|
||||
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
|
||||
>::type
|
||||
>
|
||||
static L_INTERNAL_WRAPPER_CONSTEXPR CppType *getCppPtrFromC (CType *cObject) {
|
||||
#ifdef DEBUG
|
||||
typedef typename CTypeMetaInfo<CType>::cppType BaseType;
|
||||
typedef CppType DerivedType;
|
||||
|
||||
BaseType *cppObject = reinterpret_cast<WrappedClonableObject<BaseType> *>(cObject)->cppPtr;
|
||||
BaseType *cppObject = reinterpret_cast<typename WrappedObjectResolver<BaseType>::type *>(cObject)->cppPtr;
|
||||
if (!cppObject)
|
||||
abort("Cpp Object is null.");
|
||||
|
||||
|
|
@ -216,20 +267,22 @@ public:
|
|||
|
||||
return derivedCppObject;
|
||||
#else
|
||||
return reinterpret_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
|
||||
return reinterpret_cast<typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<
|
||||
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
|
||||
>::type
|
||||
>
|
||||
static L_INTERNAL_WRAPPER_CONSTEXPR const CppType *getCppPtrFromC (const CType *cObject) {
|
||||
#ifdef DEBUG
|
||||
return getCppPtrFromC(const_cast<CType *>(cObject));
|
||||
#else
|
||||
return reinterpret_cast<const WrappedClonableObject<CppType> *>(cObject)->cppPtr;
|
||||
return reinterpret_cast<const typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -240,11 +293,28 @@ public:
|
|||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static inline void setCppPtrFromC (CType *cObject, const std::shared_ptr<CppType> &cppObject) {
|
||||
reinterpret_cast<WrappedObject<CppType> *>(cObject)->cppPtr = cppObject;
|
||||
cppObject->setProperty("LinphonePrivate::Wrapper::cBackPtr", cObject);
|
||||
cppObject->setCBackPtr(cObject);
|
||||
}
|
||||
|
||||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<
|
||||
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
|
||||
>::type
|
||||
>
|
||||
static inline void setCppPtrFromC (CType *cObject, CppType* &&cppObject) {
|
||||
CppType **cppObjectAddr = &reinterpret_cast<typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
|
||||
if (*cppObjectAddr == cppObject)
|
||||
return;
|
||||
delete *cppObjectAddr;
|
||||
|
||||
*cppObjectAddr = cppObject;
|
||||
(*cppObjectAddr)->setCBackPtr(cObject);
|
||||
}
|
||||
|
||||
template<
|
||||
|
|
@ -259,7 +329,7 @@ public:
|
|||
delete *cppObjectAddr;
|
||||
|
||||
*cppObjectAddr = new CppType(*cppObject);
|
||||
(*cppObjectAddr)->setProperty("LinphonePrivate::Wrapper::cBackPtr", cObject);
|
||||
(*cppObjectAddr)->setCBackPtr(cObject);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -268,34 +338,28 @@ public:
|
|||
|
||||
template<
|
||||
typename CppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value>::type
|
||||
>
|
||||
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const std::shared_ptr<CppType> &cppObject) {
|
||||
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
|
||||
|
||||
if (L_UNLIKELY(!cppObject))
|
||||
return nullptr;
|
||||
|
||||
Variant variant = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
|
||||
void *value = variant.getValue<void *>();
|
||||
if (value)
|
||||
return static_cast<RetType *>(value);
|
||||
|
||||
RetType *cObject = CppTypeMetaInfo<CppType>::init();
|
||||
setCppPtrFromC(cObject, cppObject);
|
||||
return cObject;
|
||||
static inline CppType * &&getResolvedCppPtr (const CppType *cppObject) {
|
||||
// Exists only for `getCBackPtr` impl.
|
||||
abort("Cannot get resolved cpp ptr from BaseObject.");
|
||||
return std::move(const_cast<CppType *>(cppObject));
|
||||
}
|
||||
|
||||
template<
|
||||
typename CppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (CppType *cppObject) {
|
||||
static inline std::shared_ptr<CppType> getResolvedCppPtr (const CppType *cppObject) {
|
||||
if (L_UNLIKELY(!cppObject))
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
return getCBackPtr(std::static_pointer_cast<CppType>(cppObject->getSharedFromThis()));
|
||||
typedef typename std::decay<decltype(*cppObject->getSharedFromThis())>::type SharedFromThisType;
|
||||
|
||||
return std::static_pointer_cast<CppType>(
|
||||
std::const_pointer_cast<SharedFromThisType>(cppObject->getSharedFromThis())
|
||||
);
|
||||
} catch (const std::bad_weak_ptr &e) {
|
||||
abort(e.what());
|
||||
}
|
||||
|
|
@ -308,19 +372,29 @@ public:
|
|||
typename CppType,
|
||||
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static constexpr const CppType *getResolvedCppPtr (const CppType *cppObject) {
|
||||
return cppObject;
|
||||
}
|
||||
|
||||
template<
|
||||
typename CppType,
|
||||
typename = typename std::enable_if<IsRegisteredCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const CppType *cppObject) {
|
||||
if (L_UNLIKELY(!cppObject))
|
||||
return nullptr;
|
||||
|
||||
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
|
||||
|
||||
Variant variant = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
|
||||
void *value = variant.getValue<void *>();
|
||||
if (value)
|
||||
void *value = cppObject->getCBackPtr();
|
||||
if (value || IsDefinedBaseCppObject<CppType>::value)
|
||||
return static_cast<RetType *>(value);
|
||||
|
||||
RetType *cObject = CppTypeMetaInfo<CppType>::init();
|
||||
setCppPtrFromC(cObject, cppObject);
|
||||
|
||||
// Can be set only on Object or ClonableObject. Not BaseObject.
|
||||
setCppPtrFromC(cObject, getResolvedCppPtr(cppObject));
|
||||
|
||||
return cObject;
|
||||
}
|
||||
|
||||
|
|
@ -364,12 +438,12 @@ public:
|
|||
|
||||
template<
|
||||
typename CppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static inline bctbx_list_t *getResolvedCListFromCppList (const std::list<std::shared_ptr<CppType>> &cppList) {
|
||||
bctbx_list_t *result = nullptr;
|
||||
for (const auto &value : cppList) {
|
||||
result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(value)));
|
||||
result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(value.get())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -388,7 +462,7 @@ public:
|
|||
template<
|
||||
typename CType,
|
||||
typename CppType = typename CTypeMetaInfo<CType>::cppType,
|
||||
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
|
||||
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
|
||||
>
|
||||
static inline std::list<std::shared_ptr<CppType>> getResolvedCppListFromCList (const bctbx_list_t *cList) {
|
||||
std::list<std::shared_ptr<CppType>> result;
|
||||
|
|
@ -500,6 +574,30 @@ LINPHONE_END_NAMESPACE
|
|||
// C object declaration.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Declare base wrapped C object.
|
||||
#define L_DECLARE_C_BASE_OBJECT_IMPL(C_TYPE, ...) \
|
||||
static_assert(LinphonePrivate::CTypeMetaInfo<Linphone ## C_TYPE>::defined, "Type is not defined."); \
|
||||
struct _Linphone ## C_TYPE { \
|
||||
belle_sip_object_t base; \
|
||||
L_CPP_TYPE_OF_C_TYPE(C_TYPE) *cppPtr; \
|
||||
__VA_ARGS__ \
|
||||
}; \
|
||||
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \
|
||||
Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init() { \
|
||||
return belle_sip_object_new(Linphone ## C_TYPE); \
|
||||
} \
|
||||
static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE * object) { \
|
||||
delete object->cppPtr; \
|
||||
} \
|
||||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## C_TYPE); \
|
||||
BELLE_SIP_INSTANCIATE_VPTR( \
|
||||
Linphone ## C_TYPE, belle_sip_object_t, \
|
||||
_linphone_ ## C_TYPE ## _uninit, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
FALSE \
|
||||
);
|
||||
|
||||
// Declare wrapped C object with constructor/destructor.
|
||||
#define L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(C_TYPE, CONSTRUCTOR, DESTRUCTOR, ...) \
|
||||
struct _Linphone ## C_TYPE { \
|
||||
|
|
@ -511,6 +609,7 @@ LINPHONE_END_NAMESPACE
|
|||
|
||||
// Declare wrapped C object.
|
||||
#define L_DECLARE_C_OBJECT_IMPL(C_TYPE, ...) \
|
||||
static_assert(LinphonePrivate::CTypeMetaInfo<Linphone ## C_TYPE>::defined, "Type is not defined."); \
|
||||
struct _Linphone ## C_TYPE { \
|
||||
belle_sip_object_t base; \
|
||||
std::shared_ptr<L_CPP_TYPE_OF_C_TYPE(C_TYPE)> cppPtr; \
|
||||
|
|
@ -519,7 +618,7 @@ LINPHONE_END_NAMESPACE
|
|||
L_INTERNAL_DECLARE_C_OBJECT_FUNCTIONS(C_TYPE, L_INTERNAL_C_OBJECT_NO_XTOR, L_INTERNAL_C_OBJECT_NO_XTOR)
|
||||
|
||||
// Declare clonable wrapped C object.
|
||||
#define L_DECLARE_C_CLONABLE_STRUCT_IMPL(C_TYPE, ...) \
|
||||
#define L_DECLARE_C_CLONABLE_OBJECT_IMPL(C_TYPE, ...) \
|
||||
static_assert(LinphonePrivate::CTypeMetaInfo<Linphone ## C_TYPE>::defined, "Type is not defined."); \
|
||||
struct _Linphone ## C_TYPE { \
|
||||
belle_sip_object_t base; \
|
||||
|
|
@ -602,7 +701,7 @@ LINPHONE_END_NAMESPACE
|
|||
|
||||
// Get the wrapped C object of a C++ object.
|
||||
#define L_GET_C_BACK_PTR(CPP_OBJECT) \
|
||||
LinphonePrivate::Wrapper::getCBackPtr(CPP_OBJECT)
|
||||
LinphonePrivate::Wrapper::getCBackPtr(LinphonePrivate::Utils::getPtr(CPP_OBJECT))
|
||||
|
||||
// Get/set user data on a wrapped C object.
|
||||
#define L_GET_USER_DATA_FROM_C_OBJECT(C_OBJECT) \
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ private:
|
|||
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE_T(ClientGroupChatRoom, ChatRoom);
|
||||
L_DECLARE_PRIVATE(ClientGroupChatRoom);
|
||||
L_DISABLE_COPY(ClientGroupChatRoom);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
bool isEmpty () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE_T(Content, ClonableObject);
|
||||
L_DECLARE_PRIVATE(Content);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -41,18 +41,6 @@ CallEvent::CallEvent (Type type, time_t time, const shared_ptr<Call> &call) :
|
|||
d->call = call;
|
||||
}
|
||||
|
||||
CallEvent::CallEvent (const CallEvent &src) : CallEvent(src.getType(), src.getTime(), src.getCall()) {}
|
||||
|
||||
CallEvent &CallEvent::operator= (const CallEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
EventLog::operator=(src);
|
||||
d->call = src.getPrivate()->call;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
shared_ptr<Call> CallEvent::getCall () const {
|
||||
L_D();
|
||||
return d->call;
|
||||
|
|
|
|||
|
|
@ -34,14 +34,12 @@ class CallEventPrivate;
|
|||
class LINPHONE_PUBLIC CallEvent : public EventLog {
|
||||
public:
|
||||
CallEvent (Type type, std::time_t time, const std::shared_ptr<Call> &message);
|
||||
CallEvent (const CallEvent &src);
|
||||
|
||||
CallEvent &operator= (const CallEvent &src);
|
||||
|
||||
std::shared_ptr<Call> getCall () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(CallEvent);
|
||||
L_DISABLE_COPY(CallEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -42,20 +42,6 @@ ChatMessageEvent::ChatMessageEvent (
|
|||
d->chatMessage = chatMessage;
|
||||
}
|
||||
|
||||
ChatMessageEvent::ChatMessageEvent (
|
||||
const ChatMessageEvent &src
|
||||
) : ChatMessageEvent(src.getTime(), src.getChatMessage()) {}
|
||||
|
||||
ChatMessageEvent &ChatMessageEvent::operator= (const ChatMessageEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
EventLog::operator=(src);
|
||||
d->chatMessage = src.getPrivate()->chatMessage;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatMessageEvent::getChatMessage () const {
|
||||
L_D();
|
||||
return d->chatMessage;
|
||||
|
|
|
|||
|
|
@ -34,14 +34,12 @@ class ChatMessageEventPrivate;
|
|||
class LINPHONE_PUBLIC ChatMessageEvent : public EventLog {
|
||||
public:
|
||||
ChatMessageEvent (std::time_t time, const std::shared_ptr<ChatMessage> &chatMessage);
|
||||
ChatMessageEvent (const ChatMessageEvent &src);
|
||||
|
||||
ChatMessageEvent &operator= (const ChatMessageEvent &src);
|
||||
|
||||
std::shared_ptr<ChatMessage> getChatMessage () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ChatMessageEvent);
|
||||
L_DISABLE_COPY(ChatMessageEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ ConferenceEvent::ConferenceEvent (Type type, time_t time, const Address &confere
|
|||
d->conferenceAddress = conferenceAddress;
|
||||
}
|
||||
|
||||
ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) :
|
||||
ConferenceEvent(src.getType(), src.getTime(), src.getConferenceAddress()) {}
|
||||
|
||||
ConferenceEvent::ConferenceEvent (
|
||||
ConferenceEventPrivate &p,
|
||||
Type type,
|
||||
|
|
@ -46,16 +43,6 @@ ConferenceEvent::ConferenceEvent (
|
|||
d->conferenceAddress = conferenceAddress;
|
||||
}
|
||||
|
||||
ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
EventLog::operator=(src);
|
||||
d->conferenceAddress = src.getPrivate()->conferenceAddress;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Address &ConferenceEvent::getConferenceAddress () const {
|
||||
L_D();
|
||||
return d->conferenceAddress;
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ class ConferenceEventPrivate;
|
|||
class LINPHONE_PUBLIC ConferenceEvent : public EventLog {
|
||||
public:
|
||||
ConferenceEvent (Type type, std::time_t time, const Address &conferenceAddress);
|
||||
ConferenceEvent (const ConferenceEvent &src);
|
||||
|
||||
ConferenceEvent &operator= (const ConferenceEvent &src);
|
||||
|
||||
const Address &getConferenceAddress () const;
|
||||
|
||||
|
|
@ -43,6 +40,7 @@ protected:
|
|||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceEvent);
|
||||
L_DISABLE_COPY(ConferenceEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -37,15 +37,6 @@ ConferenceNotifiedEvent::ConferenceNotifiedEvent (
|
|||
d->notifyId = notifyId;
|
||||
}
|
||||
|
||||
ConferenceNotifiedEvent::ConferenceNotifiedEvent (
|
||||
const ConferenceNotifiedEvent &src
|
||||
) : ConferenceNotifiedEvent(
|
||||
src.getType(),
|
||||
src.getTime(),
|
||||
src.getConferenceAddress(),
|
||||
src.getNotifyId()
|
||||
) {}
|
||||
|
||||
ConferenceNotifiedEvent::ConferenceNotifiedEvent (
|
||||
ConferenceNotifiedEventPrivate &p,
|
||||
Type type,
|
||||
|
|
@ -57,16 +48,6 @@ ConferenceNotifiedEvent::ConferenceNotifiedEvent (
|
|||
d->notifyId = notifyId;
|
||||
}
|
||||
|
||||
ConferenceNotifiedEvent &ConferenceNotifiedEvent::operator= (const ConferenceNotifiedEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
ConferenceEvent::operator=(src);
|
||||
d->notifyId = src.getPrivate()->notifyId;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int ConferenceNotifiedEvent::getNotifyId () const {
|
||||
L_D();
|
||||
return d->notifyId;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ class ConferenceNotifiedEventPrivate;
|
|||
class LINPHONE_PUBLIC ConferenceNotifiedEvent : public ConferenceEvent {
|
||||
public:
|
||||
ConferenceNotifiedEvent (Type type, std::time_t time, const Address &conferenceAddress, unsigned int notifiyId);
|
||||
ConferenceNotifiedEvent (const ConferenceNotifiedEvent &src);
|
||||
|
||||
ConferenceNotifiedEvent &operator= (const ConferenceNotifiedEvent &src);
|
||||
|
||||
unsigned int getNotifyId () const;
|
||||
|
||||
|
|
@ -48,6 +45,7 @@ protected:
|
|||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceNotifiedEvent);
|
||||
L_DISABLE_COPY(ConferenceNotifiedEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -56,28 +56,6 @@ ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
|
|||
d->gruuAddress = gruuAddress;
|
||||
}
|
||||
|
||||
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (const ConferenceParticipantDeviceEvent &src) :
|
||||
ConferenceParticipantDeviceEvent(
|
||||
src.getType(),
|
||||
src.getTime(),
|
||||
src.getConferenceAddress(),
|
||||
src.getNotifyId(),
|
||||
src.getParticipantAddress(),
|
||||
src.getGruuAddress()
|
||||
) {}
|
||||
|
||||
ConferenceParticipantDeviceEvent &ConferenceParticipantDeviceEvent::operator= (
|
||||
const ConferenceParticipantDeviceEvent &src
|
||||
) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
ConferenceParticipantEvent::operator=(src);
|
||||
d->gruuAddress = src.getPrivate()->gruuAddress;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Address &ConferenceParticipantDeviceEvent::getGruuAddress () const {
|
||||
L_D();
|
||||
return d->gruuAddress;
|
||||
|
|
|
|||
|
|
@ -38,14 +38,12 @@ public:
|
|||
const Address &participantAddress,
|
||||
const Address &gruuAddress
|
||||
);
|
||||
ConferenceParticipantDeviceEvent (const ConferenceParticipantDeviceEvent &src);
|
||||
|
||||
ConferenceParticipantDeviceEvent &operator= (const ConferenceParticipantDeviceEvent &src);
|
||||
|
||||
const Address &getGruuAddress () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceParticipantDeviceEvent);
|
||||
L_DISABLE_COPY(ConferenceParticipantDeviceEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -44,16 +44,6 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
|
|||
d->participantAddress = participantAddress;
|
||||
}
|
||||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
const ConferenceParticipantEvent &src
|
||||
) : ConferenceParticipantEvent(
|
||||
src.getType(),
|
||||
src.getTime(),
|
||||
src.getConferenceAddress(),
|
||||
src.getNotifyId(),
|
||||
src.getParticipantAddress()
|
||||
) {}
|
||||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
ConferenceParticipantEventPrivate &p,
|
||||
Type type,
|
||||
|
|
@ -66,16 +56,6 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
|
|||
d->participantAddress = participantAddress;
|
||||
}
|
||||
|
||||
ConferenceParticipantEvent &ConferenceParticipantEvent::operator= (const ConferenceParticipantEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
ConferenceEvent::operator=(src);
|
||||
d->participantAddress = src.getPrivate()->participantAddress;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Address &ConferenceParticipantEvent::getParticipantAddress () const {
|
||||
L_D();
|
||||
return d->participantAddress;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ public:
|
|||
unsigned int notifyId,
|
||||
const Address &participantAddress
|
||||
);
|
||||
ConferenceParticipantEvent (const ConferenceParticipantEvent &src);
|
||||
|
||||
ConferenceParticipantEvent &operator= (const ConferenceParticipantEvent &src);
|
||||
|
||||
const Address &getParticipantAddress () const;
|
||||
|
||||
|
|
@ -55,6 +52,7 @@ protected:
|
|||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceParticipantEvent);
|
||||
L_DISABLE_COPY(ConferenceParticipantEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -49,19 +49,6 @@ ConferenceSubjectEvent::ConferenceSubjectEvent (
|
|||
d->subject = subject;
|
||||
}
|
||||
|
||||
ConferenceSubjectEvent::ConferenceSubjectEvent (const ConferenceSubjectEvent &src) :
|
||||
ConferenceSubjectEvent(src.getTime(), src.getConferenceAddress(), src.getNotifyId(), src.getSubject()) {}
|
||||
|
||||
ConferenceSubjectEvent &ConferenceSubjectEvent::operator= (const ConferenceSubjectEvent &src) {
|
||||
L_D();
|
||||
if (this != &src) {
|
||||
ConferenceEvent::operator=(src);
|
||||
d->subject = src.getPrivate()->subject;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const string &ConferenceSubjectEvent::getSubject () const {
|
||||
L_D();
|
||||
return d->subject;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#ifndef _CONFERENCE_SUBJECT_EVENT_H_
|
||||
#define _CONFERENCE_SUBJECT_EVENT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "conference-notified-event.h"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -36,14 +38,12 @@ public:
|
|||
unsigned int notifyId,
|
||||
const std::string &subject
|
||||
);
|
||||
ConferenceSubjectEvent (const ConferenceSubjectEvent &src);
|
||||
|
||||
ConferenceSubjectEvent &operator= (const ConferenceSubjectEvent &src);
|
||||
|
||||
const std::string &getSubject () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceSubjectEvent);
|
||||
L_DISABLE_COPY(ConferenceSubjectEvent);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -20,14 +20,15 @@
|
|||
#ifndef _EVENT_LOG_P_H_
|
||||
#define _EVENT_LOG_P_H_
|
||||
|
||||
#include "object/base-object-p.h"
|
||||
|
||||
#include "event-log.h"
|
||||
#include "object/clonable-object-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class EventLogPrivate : public ClonableObjectPrivate {
|
||||
class EventLogPrivate : public BaseObjectPrivate {
|
||||
public:
|
||||
long storageId = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,23 +23,14 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
EventLog::EventLog () : ClonableObject(*new EventLogPrivate) {}
|
||||
EventLog::EventLog () : BaseObject(*new EventLogPrivate) {}
|
||||
|
||||
EventLog::EventLog (const EventLog &) : ClonableObject(*new EventLogPrivate) {}
|
||||
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type, time_t time) : ClonableObject(*new EventLogPrivate) {
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type, std::time_t time) : BaseObject(p) {
|
||||
L_D();
|
||||
d->type = type;
|
||||
d->time = time;
|
||||
}
|
||||
|
||||
EventLog &EventLog::operator= (const EventLog &src) {
|
||||
L_D();
|
||||
if (this != &src)
|
||||
d->type = src.getPrivate()->type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
EventLog::Type EventLog::getType () const {
|
||||
L_D();
|
||||
return d->type;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "linphone/enums/event-log-enums.h"
|
||||
#include "linphone/utils/enum-generator.h"
|
||||
|
||||
#include "object/clonable-object.h"
|
||||
#include "object/base-object.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -33,16 +33,13 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
class EventLogPrivate;
|
||||
|
||||
class LINPHONE_PUBLIC EventLog : public ClonableObject {
|
||||
class LINPHONE_PUBLIC EventLog : public BaseObject {
|
||||
friend class MainDb;
|
||||
|
||||
public:
|
||||
L_DECLARE_ENUM(Type, L_ENUM_VALUES_EVENT_LOG_TYPE);
|
||||
|
||||
EventLog ();
|
||||
EventLog (const EventLog &src);
|
||||
|
||||
EventLog &operator= (const EventLog &src);
|
||||
|
||||
Type getType () const;
|
||||
std::time_t getTime () const;
|
||||
|
|
@ -52,6 +49,7 @@ protected:
|
|||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(EventLog);
|
||||
L_DISABLE_COPY(EventLog);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
47
src/object/base-object-p.h
Normal file
47
src/object/base-object-p.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* base-object-p.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 _BASE_OBJECT_P_H_
|
||||
#define _BASE_OBJECT_P_H_
|
||||
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
#include "object-head-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class BaseObjectPrivate {
|
||||
L_OBJECT_PRIVATE;
|
||||
|
||||
public:
|
||||
BaseObjectPrivate () = default;
|
||||
virtual ~BaseObjectPrivate () = default;
|
||||
|
||||
protected:
|
||||
BaseObject *mPublic = nullptr;
|
||||
|
||||
private:
|
||||
L_DECLARE_PUBLIC(BaseObject);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _BASE_OBJECT_P_H_
|
||||
38
src/object/base-object.cpp
Normal file
38
src/object/base-object.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* base-object.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 "base-object-p.h"
|
||||
|
||||
#include "base-object.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
L_OBJECT_IMPL(BaseObject);
|
||||
|
||||
BaseObject::BaseObject (BaseObjectPrivate &p) : mPrivate(&p) {
|
||||
mPrivate->mPublic = this;
|
||||
}
|
||||
|
||||
BaseObject::~BaseObject () {
|
||||
delete mPrivate;
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
56
src/object/base-object.h
Normal file
56
src/object/base-object.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* base-object.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 _BASE_OBJECT_H_
|
||||
#define _BASE_OBJECT_H_
|
||||
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
#include "object-head.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class BaseObjectPrivate;
|
||||
|
||||
/*
|
||||
* Base Object of Linphone. Cannot be cloned. Cannot be Shared.
|
||||
* It's the base class of Object. It's useful for lightweight entities
|
||||
* like Events.
|
||||
*/
|
||||
class LINPHONE_PUBLIC BaseObject {
|
||||
L_OBJECT;
|
||||
|
||||
public:
|
||||
virtual ~BaseObject ();
|
||||
|
||||
protected:
|
||||
explicit BaseObject (BaseObjectPrivate &p);
|
||||
|
||||
BaseObjectPrivate *mPrivate = nullptr;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(BaseObject);
|
||||
L_DISABLE_COPY(BaseObject);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _BASE_OBJECT_H_
|
||||
|
|
@ -24,11 +24,15 @@
|
|||
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
#include "object-head-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ClonableObjectPrivate {
|
||||
L_OBJECT_PRIVATE;
|
||||
|
||||
public:
|
||||
ClonableObjectPrivate () = default;
|
||||
virtual ~ClonableObjectPrivate () = default;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ void ClonableObjectPrivate::unref () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
L_OBJECT_IMPL(ClonableObject);
|
||||
|
||||
ClonableObject::ClonableObject (ClonableObjectPrivate &p) : mPrivate(&p) {
|
||||
// Q-pointer must be empty. It's a constructor that takes a new private data.
|
||||
L_ASSERT(!mPrivate->mPublic);
|
||||
|
|
|
|||
|
|
@ -20,13 +20,20 @@
|
|||
#ifndef _CLONABLE_OBJECT_H_
|
||||
#define _CLONABLE_OBJECT_H_
|
||||
|
||||
#include "object-head.h"
|
||||
#include "property-container.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
/*
|
||||
* Clonable Object of Linphone. Generally it's just a data object with no
|
||||
* intelligence.
|
||||
*/
|
||||
class LINPHONE_PUBLIC ClonableObject : public PropertyContainer {
|
||||
L_OBJECT;
|
||||
|
||||
public:
|
||||
virtual ~ClonableObject ();
|
||||
|
||||
|
|
|
|||
38
src/object/object-head-p.h
Normal file
38
src/object/object-head-p.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* object-head-p.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 _OBJECT_HEAD_P_H_
|
||||
#define _OBJECT_HEAD_P_H_
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#define L_OBJECT_IMPL(CLASS) \
|
||||
void *CLASS::getCBackPtr () const { \
|
||||
L_D(); \
|
||||
return d->cBackPtr; \
|
||||
} \
|
||||
void CLASS::setCBackPtr (void *cBackPtr) { \
|
||||
L_D(); \
|
||||
d->cBackPtr = cBackPtr; \
|
||||
}
|
||||
|
||||
#define L_OBJECT_PRIVATE \
|
||||
void *cBackPtr = nullptr;
|
||||
|
||||
#endif // ifndef _OBJECT_HEAD_P_H_
|
||||
29
src/object/object-head.h
Normal file
29
src/object/object-head.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* object-head.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 _OBJECT_HEAD_H_
|
||||
#define _OBJECT_HEAD_H_
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#define L_OBJECT \
|
||||
void *getCBackPtr () const; \
|
||||
void setCBackPtr (void *cBackPtr);
|
||||
|
||||
#endif // ifndef _OBJECT_HEAD_H_
|
||||
|
|
@ -23,21 +23,16 @@
|
|||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base-object-p.h"
|
||||
#include "variant/variant.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ObjectPrivate {
|
||||
class ObjectPrivate : public BaseObjectPrivate {
|
||||
friend class ObjectFactory;
|
||||
|
||||
public:
|
||||
virtual ~ObjectPrivate () = default;
|
||||
|
||||
protected:
|
||||
Object *mPublic = nullptr;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, Variant> properties;
|
||||
std::weak_ptr<Object> weak;
|
||||
|
|
|
|||
|
|
@ -30,13 +30,7 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
Object::Object (ObjectPrivate &p) : mPrivate(&p) {
|
||||
mPrivate->mPublic = this;
|
||||
}
|
||||
|
||||
Object::~Object () {
|
||||
delete mPrivate;
|
||||
}
|
||||
Object::Object (ObjectPrivate &p) : BaseObject(p) {}
|
||||
|
||||
shared_ptr<Object> Object::getSharedFromThis () {
|
||||
return const_pointer_cast<Object>(static_cast<const Object *>(this)->getSharedFromThis());
|
||||
|
|
@ -46,7 +40,7 @@ shared_ptr<const Object> Object::getSharedFromThis () const {
|
|||
shared_ptr<const Object> object;
|
||||
|
||||
try {
|
||||
object = mPrivate->weak.lock();
|
||||
object = getPrivate()->weak.lock();
|
||||
if (!object)
|
||||
lFatal() << GET_SHARED_FROM_THIS_FATAL_ERROR;
|
||||
} catch (const exception &) {
|
||||
|
|
|
|||
|
|
@ -22,17 +22,22 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "base-object.h"
|
||||
#include "property-container.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class LINPHONE_PUBLIC Object : public PropertyContainer {
|
||||
/*
|
||||
* Main Object of Linphone. Can be shared but is not Clonable.
|
||||
* Must be built with ObjectFactory.
|
||||
*/
|
||||
class LINPHONE_PUBLIC Object : public BaseObject, public PropertyContainer {
|
||||
friend class ObjectFactory;
|
||||
|
||||
public:
|
||||
virtual ~Object ();
|
||||
virtual ~Object () = default;
|
||||
|
||||
protected:
|
||||
explicit Object (ObjectPrivate &p);
|
||||
|
|
@ -40,8 +45,6 @@ protected:
|
|||
std::shared_ptr<Object> getSharedFromThis ();
|
||||
std::shared_ptr<const Object> getSharedFromThis () const;
|
||||
|
||||
ObjectPrivate *mPrivate = nullptr;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(Object);
|
||||
L_DISABLE_COPY(Object);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue