Skip to content
Snippets Groups Projects
Commit 8ebf1386 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Use GeoIntrusivePtr instead of GeoRef

parent bc8a760c
No related branches found
No related tags found
1 merge request!68773GeoModelUtilities - Use GeoIntrusivePtr instead of GeoRef
......@@ -15,106 +15,8 @@
#ifndef GEOMODELUTILITIES_GEOREF_H
#define GEOMODELUTILITIES_GEOREF_H
#include "GeoModelKernel/GeoIntrusivePtr.h"
template <class T>
class GeoRef
{
public:
GeoRef (T* p = nullptr) noexcept
: m_p (p)
{
if (m_p) m_p->ref();
}
~GeoRef() noexcept
{
if (m_p) m_p->unref();
}
GeoRef (const GeoRef& o) noexcept
: m_p (o.m_p)
{
if (m_p) m_p->ref();
}
template <class U>
GeoRef (GeoRef<U>& o) noexcept
: m_p (o.get())
{
if (m_p) m_p->ref();
}
GeoRef (GeoRef&& o) noexcept
: m_p (o.m_p)
{
o.m_p = nullptr;
}
GeoRef& operator= (const GeoRef& o) noexcept
{
if (this != &o) {
if (m_p) m_p->unref();
m_p = o.m_p;
if (m_p) m_p->ref();
}
return *this;
}
template <class U>
GeoRef& operator= (GeoRef<U>& o) noexcept
{
if (m_p) m_p->unref();
m_p = o.get();
if (m_p) m_p->ref();
return *this;
}
GeoRef& operator= (GeoRef&& o) noexcept
{
if (this != &o) {
if (m_p) m_p->unref();
m_p = o.m_p;
o.m_p = nullptr;
}
return *this;
}
operator T*() noexcept
{
return m_p;
}
T* get() noexcept
{
return m_p;
}
T* operator->() noexcept
{
return m_p;
}
T& operator*() noexcept
{
return *m_p;
}
private:
T* m_p;
};
template <class T> using GeoRef = GeoIntrusivePtr<T>;
#endif // not GEOMODELUTILITIES_GEOREF_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment