mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 00:29:21 +00:00
feat(General): provide a way to get private data in a a multiple inheritance case.
This commit is contained in:
parent
a1fe2223f0
commit
e12b123cf0
2 changed files with 30 additions and 4 deletions
|
|
@ -20,6 +20,10 @@
|
|||
#ifndef _GENERAL_H_
|
||||
#define _GENERAL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -151,8 +155,30 @@ constexpr T *getPublicHelper (Object *object, const ObjectPrivate *) {
|
|||
CLASS (const CLASS &) = delete; \
|
||||
CLASS &operator= (const CLASS &) = delete;
|
||||
|
||||
#define L_D() decltype(std::declval<decltype(*this)>().getPrivate()) const d = getPrivate();
|
||||
#define L_Q() decltype(std::declval<decltype(*this)>().getPublic()) const q = getPublic();
|
||||
// Get Private data.
|
||||
#define L_D() decltype(getPrivate()) const d = getPrivate();
|
||||
|
||||
// Get Public data.
|
||||
#define L_Q() decltype(getPublic()) const q = getPublic();
|
||||
|
||||
template<typename T, typename U>
|
||||
struct AddConstMirror {
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template<typename T, typename U>
|
||||
struct AddConstMirror<const T, U> {
|
||||
typedef typename std::add_const<U>::type type;
|
||||
};
|
||||
|
||||
// Get Private data of class in a multiple inheritance case.
|
||||
#define L_D_T(CLASS, NAME) \
|
||||
auto const NAME = static_cast< \
|
||||
AddConstMirror< \
|
||||
std::remove_reference<decltype(*this)>::type, \
|
||||
CLASS ## Private \
|
||||
>::type * \
|
||||
>(CLASS::mPrivate);
|
||||
|
||||
#define L_OVERRIDE_SHARED_FROM_THIS(CLASS) \
|
||||
inline std::shared_ptr<CLASS> getSharedFromThis () { \
|
||||
|
|
|
|||
|
|
@ -211,6 +211,7 @@ void ClientGroupChatRoom::setParticipantAdminStatus (shared_ptr<Participant> &pa
|
|||
|
||||
void ClientGroupChatRoom::setSubject (const string &subject) {
|
||||
L_D();
|
||||
L_D_T(RemoteConference, dConference);
|
||||
|
||||
if (d->state != ChatRoom::State::Created) {
|
||||
lError() << "Cannot change the ClientGroupChatRoom subject in a state other than Created";
|
||||
|
|
@ -222,8 +223,7 @@ void ClientGroupChatRoom::setSubject (const string &subject) {
|
|||
return;
|
||||
}
|
||||
|
||||
shared_ptr<CallSession> session =
|
||||
static_cast<RemoteConferencePrivate *>(Conference::mPrivate)->focus->getPrivate()->getSession();
|
||||
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
|
||||
if (session)
|
||||
session->update(nullptr, subject);
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue