Skip to content
Snippets Groups Projects

GeoModelUtilities - Use GeoIntrusivePtr instead of GeoRef

Merged Johannes Junggeburth requested to merge jojungge/athena:ReplaceGeoRef into main
1 file
+ 2
100
Compare changes
  • Side-by-side
  • Inline
@@ -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
Loading