App: implement '*' operator for weak pointer classes

This commit is contained in:
wmayer
2022-06-13 13:52:21 +02:00
parent b82230867b
commit 1f606e40e1
2 changed files with 33 additions and 6 deletions

View File

@@ -593,7 +593,12 @@ bool DocumentWeakPtrT::expired() const noexcept
return (d->_document == nullptr);
}
App::Document* DocumentWeakPtrT::operator->() noexcept
App::Document* DocumentWeakPtrT::operator*() const noexcept
{
return d->_document;
}
App::Document* DocumentWeakPtrT::operator->() const noexcept
{
return d->_document;
}
@@ -686,7 +691,12 @@ DocumentObjectWeakPtrT& DocumentObjectWeakPtrT::operator= (App::DocumentObject*
return *this;
}
App::DocumentObject* DocumentObjectWeakPtrT::operator->() noexcept
App::DocumentObject* DocumentObjectWeakPtrT::operator*() const noexcept
{
return d->get();
}
App::DocumentObject* DocumentObjectWeakPtrT::operator->() const noexcept
{
return d->get();
}

View File

@@ -294,11 +294,16 @@ public:
* \return true if the managed object has already been deleted, false otherwise.
*/
bool expired() const noexcept;
/*!
* \brief operator *
* \return pointer to the document
*/
App::Document* operator*() const noexcept;
/*!
* \brief operator ->
* \return pointer to the document
*/
App::Document* operator->() noexcept;
App::Document* operator->() const noexcept;
private:
// disable
@@ -334,10 +339,15 @@ public:
*/
DocumentObjectWeakPtrT& operator= (App::DocumentObject* p);
/*!
* \brief operator ->
* \return pointer to the document
* \brief operator *
* \return pointer to the document object
*/
App::DocumentObject* operator->() noexcept;
App::DocumentObject* operator*() const noexcept;
/*!
* \brief operator ->
* \return pointer to the document object
*/
App::DocumentObject* operator->() const noexcept;
/*!
* \brief operator ==
* \return true if both objects are equal, false otherwise
@@ -400,6 +410,13 @@ public:
ptr = p;
return *this;
}
/*!
* \brief operator ->
* \return pointer to the document object
*/
T* operator*() const {
return ptr.get<T>();
}
/*!
* \brief operator ->
* \return pointer to the document object