From 1ff50ec17953d722c9558d843acbe7220dd6fcd8 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 8 Sep 2017 09:23:57 +0200 Subject: [PATCH] feat(Events): finish impl --- src/c-wrapper/c-tools.h | 15 +++++++++++---- src/event-log/conference-event.cpp | 14 ++++++-------- src/event-log/conference-participant-event.cpp | 11 +++++------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/c-wrapper/c-tools.h b/src/c-wrapper/c-tools.h index 9d8975fb8..8f4b6d738 100644 --- a/src/c-wrapper/c-tools.h +++ b/src/c-wrapper/c-tools.h @@ -47,18 +47,22 @@ public: template static inline std::shared_ptr getCppPtrFromC (void *object) { - if (!object) - return std::shared_ptr(); + L_ASSERT(object); return static_cast *>(object)->cppPtr; } template static inline std::shared_ptr getCppPtrFromC (const void *object) { - if (!object) - return std::shared_ptr(); + L_ASSERT(object); return static_cast *>(object)->cppPtr; } + template + static inline void setCppPtrFromC (void *object, std::shared_ptr &cppPtr) { + L_ASSERT(object); + static_cast *>(object)->cppPtr = cppPtr; + } + private: Wrapper (); @@ -108,6 +112,9 @@ LINPHONE_END_NAMESPACE #define L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, TYPE) \ LINPHONE_NAMESPACE::Wrapper::getCppPtrFromC(OBJECT) +#define L_SET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_PTR) \ + LINPHONE_NAMESPACE::Wrapper::setCppPtrFromC(OBJECT, CPP_PTR) + #define L_GET_PRIVATE(OBJECT) \ LINPHONE_NAMESPACE::Wrapper::getPrivate(OBJECT) diff --git a/src/event-log/conference-event.cpp b/src/event-log/conference-event.cpp index cfb4ca69c..16486a929 100644 --- a/src/event-log/conference-event.cpp +++ b/src/event-log/conference-event.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include "address/address.h" #include "conference-event-p.h" #include "conference-event.h" @@ -31,8 +32,7 @@ ConferenceEvent::ConferenceEvent (Type type, const shared_ptr &ad L_D(ConferenceEvent); L_ASSERT(type == TypeConferenceCreated || type == TypeConferenceDestroyed); L_ASSERT(address); - // TODO: Duplicate address. - d->address = address; + d->address = make_shared
(*address); } ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) : ConferenceEvent(src.getType(), src.getAddress()) {} @@ -41,24 +41,22 @@ ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const sh EventLog(p, type) { L_D(ConferenceEvent); L_ASSERT(address); - // TODO: Duplicate address. - d->address = address; + d->address = make_shared
(*address); } ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) { L_D(ConferenceEvent); if (this != &src) { EventLog::operator=(src); - // TODO: Duplicate address. - d->address = src.getPrivate()->address; + d->address = make_shared
(*src.getPrivate()->address); } return *this; } shared_ptr ConferenceEvent::getAddress () const { - // TODO. - return nullptr; + L_D(const ConferenceEvent); + return d->address; } LINPHONE_END_NAMESPACE diff --git a/src/event-log/conference-participant-event.cpp b/src/event-log/conference-participant-event.cpp index 0095da63a..d1d647f75 100644 --- a/src/event-log/conference-participant-event.cpp +++ b/src/event-log/conference-participant-event.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include "address/address.h" #include "conference-event-p.h" #include "conference-participant-event.h" @@ -46,8 +47,7 @@ ConferenceParticipantEvent::ConferenceParticipantEvent ( type == TypeConferenceParticipantUnsetAdmin ); L_ASSERT(participantAddress); - // TODO: Duplicate address. - d->participantAddress = participantAddress; + d->participantAddress = make_shared
(*participantAddress); } ConferenceParticipantEvent::ConferenceParticipantEvent (const ConferenceParticipantEvent &src) : @@ -57,16 +57,15 @@ ConferenceParticipantEvent &ConferenceParticipantEvent::operator= (const Confere L_D(ConferenceParticipantEvent); if (this != &src) { ConferenceEvent::operator=(src); - // TODO: Duplicate address. - d->participantAddress = src.getPrivate()->participantAddress; + d->participantAddress = make_shared
(*src.getPrivate()->participantAddress); } return *this; } shared_ptr ConferenceParticipantEvent::getParticipantAddress () const { - // TODO. - return nullptr; + L_D(const ConferenceParticipantEvent); + return d->participantAddress; } LINPHONE_END_NAMESPACE