OpenShot Library | libopenshot-audio
0.2.0
|
42 template <
class ObjectType>
58 : object (objectToHold), shouldDelete (takeOwnership)
71 : object (objectToTransferFrom.
release()),
72 shouldDelete (objectToTransferFrom.shouldDelete)
86 if (
object != objectToTransferFrom.object)
89 object.reset (objectToTransferFrom.object.release());
92 shouldDelete = objectToTransferFrom.shouldDelete;
107 inline operator ObjectType*()
const noexcept {
return object.get(); }
110 inline ObjectType*
get() const noexcept {
return object.get(); }
113 inline ObjectType&
operator*() const noexcept {
return *object; }
116 inline ObjectType*
operator->() const noexcept {
return object.get(); }
122 ObjectType*
release() noexcept {
return object.release(); }
143 void set (ObjectType* newObject,
bool takeOwnership)
145 if (
object.
get() != newObject)
148 object.reset (newObject);
151 shouldDelete = takeOwnership;
157 set (newObject,
true);
163 set (newObject,
false);
177 object.swapWith (other.object);
178 std::swap (shouldDelete, other.shouldDelete);
184 bool shouldDelete =
false;
ObjectType * operator->() const noexcept
Lets you access methods and properties of the object that this pointer is holding.
void reset()
Resets this pointer to null, possibly deleting the object that it holds, if it has ownership of it.
ObjectType * get() const noexcept
Returns the object that this pointer is managing.
ObjectType * release() noexcept
Removes the current object from this OptionalScopedPointer without deleting it.
void swapWith(OptionalScopedPointer< ObjectType > &other) noexcept
Swaps this object with another OptionalScopedPointer.
OptionalScopedPointer()=default
Creates an empty OptionalScopedPointer.
void clear()
Does the same thing as reset().
~OptionalScopedPointer()
The destructor may or may not delete the object that is being held, depending on the takeOwnership fl...
void setNonOwned(ObjectType *newObject)
Makes this OptionalScopedPointer point at a new object, but will not take ownership of that object.
bool willDeleteObject() const noexcept
Returns true if the target object will be deleted when this pointer object is deleted.
OptionalScopedPointer & operator=(OptionalScopedPointer &objectToTransferFrom)
Takes ownership of the object that another OptionalScopedPointer holds.
This class is deprecated.
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
OptionalScopedPointer(ObjectType *objectToHold, bool takeOwnership)
Creates an OptionalScopedPointer to point to a given object, and specifying whether the OptionalScope...
void setOwned(ObjectType *newObject)
Makes this OptionalScopedPointer point at a new object, and take ownership of that object.
OptionalScopedPointer(OptionalScopedPointer &objectToTransferFrom)
Takes ownership of the object that another OptionalScopedPointer holds.
ObjectType & operator*() const noexcept
Returns the object that this pointer is managing.
void set(ObjectType *newObject, bool takeOwnership)
Makes this OptionalScopedPointer point at a new object, specifying whether the OptionalScopedPointer ...