17 #ifndef DISTRHO_SCOPED_POINTER_HPP_INCLUDED
18 #define DISTRHO_SCOPED_POINTER_HPP_INCLUDED
20 #include "../DistrhoUtils.hpp"
81 template<
class ObjectType>
92 : object(objectToTakePossessionOf) {}
101 : object(objectToTransferFrom.object)
103 objectToTransferFrom.object =
nullptr;
125 if (
this != objectToTransferFrom.getAddress())
129 DISTRHO_SAFE_ASSERT_RETURN(
object ==
nullptr ||
object != objectToTransferFrom.object, *
this);
131 ObjectType*
const oldObject = object;
132 object = objectToTransferFrom.object;
133 objectToTransferFrom.object =
nullptr;
149 if (
object != newObjectToTakePossessionOf)
151 ObjectType*
const oldObject = object;
152 object = newObjectToTakePossessionOf;
161 operator ObjectType*()
const noexcept {
return object; }
164 ObjectType*
get() const noexcept {
return object; }
167 ObjectType&
getObject() const noexcept {
return *object; }
170 ObjectType&
operator*() const noexcept {
return *object; }
179 ObjectType*
release() noexcept { ObjectType*
const o = object;
object =
nullptr;
return o; }
189 DISTRHO_SAFE_ASSERT_RETURN(
object != other.object ||
this == other.getAddress() ||
object ==
nullptr,);
191 std::swap(
object, other.object);
199 const ScopedPointer* getAddress() const noexcept {
return this; }
218 # ifdef DISTRHO_PROPER_CPP11_SUPPORT
232 template<
class ObjectType>
235 return static_cast<ObjectType*
>(pointer1) == pointer2;
241 template<
class ObjectType>
244 return static_cast<ObjectType*
>(pointer1) != pointer2;
Definition: ScopedPointer.hpp:83
ScopedPointer(ScopedPointer &objectToTransferFrom) noexcept
Definition: ScopedPointer.hpp:100
ObjectType * release() noexcept
Definition: ScopedPointer.hpp:179
ObjectType & getObject() const noexcept
Definition: ScopedPointer.hpp:167
ObjectType & operator*() const noexcept
Definition: ScopedPointer.hpp:170
void swapWith(ScopedPointer< ObjectType > &other) noexcept
Definition: ScopedPointer.hpp:185
~ScopedPointer()
Definition: ScopedPointer.hpp:109
ScopedPointer(ObjectType *const objectToTakePossessionOf) noexcept
Definition: ScopedPointer.hpp:91
ObjectType * operator->() const noexcept
Definition: ScopedPointer.hpp:173
ScopedPointer & operator=(ObjectType *const newObjectToTakePossessionOf)
Definition: ScopedPointer.hpp:147
ScopedPointer() noexcept
Definition: ScopedPointer.hpp:87
ObjectType * get() const noexcept
Definition: ScopedPointer.hpp:164
ScopedPointer & operator=(ScopedPointer &objectToTransferFrom)
Definition: ScopedPointer.hpp:123
#define END_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:949
#define START_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:943