From 0579b0db2b5d5e9c500f129d02951fd10c761727 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 13 Oct 2017 11:53:00 +0200 Subject: [PATCH] feat(General): provide a L_Q_T macro to access public data in a multiple inheritance case --- include/linphone/utils/general.h | 9 +++++++++ src/chat/chat-room/client-group-chat-room.cpp | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linphone/utils/general.h b/include/linphone/utils/general.h index 1ccee3b72..7ade05a19 100644 --- a/include/linphone/utils/general.h +++ b/include/linphone/utils/general.h @@ -180,6 +180,15 @@ struct AddConstMirror { >::type * \ >(CLASS::mPrivate); +// Get Private data of class in a multiple inheritance case. +#define L_Q_T(CLASS, NAME) \ + auto const NAME = static_cast< \ + AddConstMirror< \ + std::remove_reference::type, \ + CLASS \ + >::type * \ + >(getPublic()); + #define L_OVERRIDE_SHARED_FROM_THIS(CLASS) \ inline std::shared_ptr getSharedFromThis () { \ return std::static_pointer_cast(Object::getSharedFromThis()); \ diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index aee176244..15d7d0251 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -41,11 +41,12 @@ ClientGroupChatRoomPrivate::ClientGroupChatRoomPrivate (LinphoneCore *core) : Ch shared_ptr ClientGroupChatRoomPrivate::createSession () { L_Q(); + L_Q_T(RemoteConference, qConference); CallSessionParams csp; csp.addCustomHeader("Require", "recipient-list-invite"); - shared_ptr focus = static_cast(q)->getPrivate()->focus; + shared_ptr focus = qConference->getPrivate()->focus; shared_ptr session = focus->getPrivate()->createSession(*q, &csp, false, q); const Address &myAddress = q->getMe()->getAddress(); session->configure(LinphoneCallOutgoing, nullptr, nullptr, myAddress, focus->getAddress()); @@ -58,8 +59,8 @@ shared_ptr ClientGroupChatRoomPrivate::createSession () { } void ClientGroupChatRoomPrivate::notifyReceived (string body) { - L_Q(); - static_cast(q)->getPrivate()->eventHandler->notifyReceived(body); + L_Q_T(RemoteConference, qConference); + qConference->getPrivate()->eventHandler->notifyReceived(body); } // =============================================================================