![]() |
![]() |
|
OpenThread
1.05.03.02
|
#include <owned_ptr.hpp>
Inheritance diagram for OwnedPtr< Type >:
Collaboration diagram for OwnedPtr< Type >:Public Member Functions | |
| void | Free (void) |
| OwnedPtr & | operator= (OwnedPtr &&aOther) |
| OwnedPtr & | operator= (const OwnedPtr &)=delete |
| OwnedPtr (void)=default | |
| OwnedPtr (Type *aPointer) | |
| OwnedPtr (OwnedPtr &&aOther) | |
| OwnedPtr (const OwnedPtr &)=delete | |
| OwnedPtr (OwnedPtr &)=delete | |
| OwnedPtr && | PassOwnership (void) |
| Type * | Release (void) |
| void | Reset (Type *aPointer=nullptr) |
| ~OwnedPtr (void) | |
Public Member Functions inherited from Ptr< Type > | |
| Type * | Get (void) |
| const Type * | Get (void) const |
| bool | IsNull (void) const |
| bool | operator!= (const Type *aPointer) const |
| bool | operator!= (const Ptr &aOther) const |
| Type & | operator* (void) |
| const Type & | operator* (void) const |
| Type * | operator-> (void) |
| const Type * | operator-> (void) const |
| bool | operator== (const Type *aPointer) const |
| bool | operator== (const Ptr &aOther) const |
| Ptr (void) | |
| Ptr (Type *aPointer) | |
Private Member Functions | |
| void | Delete (void) |
Additional Inherited Members | |
Protected Attributes inherited from Ptr< Type > | |
| Type * | mPointer |
This template class represents an owned smart pointer.
OwnedPtr acts as sole owner of the object it manages. An OwnedPtr is non-copyable (copy constructor is deleted) but the ownership can be transferred from one OwnedPtr to another using move semantics.
The Type class MUST provide Free() method which frees the instance.
| Type | The pointer type. |
|
default |
This is the default constructor for OwnedPtr initializing it as null.
Referenced by OwnedPtr< Type >::operator=().
|
inlineexplicit |
This constructor initializes the OwnedPtr from another OwnedPtr using move semantics.
The OwnedPtr takes over the ownership of the object from aOther. After this call, aOther will be null.
| [in] | aOther | An rvalue reference to another OwnedPtr. |
References Ptr< Type >::mPointer.
|
inline |
This is the destructor for OwnedPtr.
Upon destruction, the OwnedPtr invokes Free() method on its managed object (if any).
References OwnedPtr< Type >::Delete().
|
inline |
This method frees the owned object (if any).
This method invokes Free() method on the Type object owned by OwnedPtr (if any). It will also set the OwnedPtr to null.
References OwnedPtr< Type >::Delete(), and Ptr< Type >::mPointer.
|
inline |
This method frees the current object owned by OwnedPtr (if any) and replaces it with a new one.
The method will Free() the current object managed by OwnedPtr (if different from aPointer) before taking the ownership of the object at aPointer. The method correctly handles a self Reset() (i.e., aPointer being the same pointer as the one currently managed by OwnedPtr).
| [in] | aPointer | A pointer to the new object to replace with. |
References OwnedPtr< Type >::Delete(), and Ptr< Type >::mPointer.
Referenced by OwnedPtr< Type >::operator=().
|
inline |
This method releases the ownership of the current object in OwnedPtr (if any).
After this call, the OwnedPtr will be null.
References Ptr< Type >::mPointer.
|
inline |
This method allows passing of the ownership to another OwnedPtr using move semantics.
This method overload the assignment operator = to replace the object owned by the OwnedPtr with another one using move semantics.
The OwnedPtr first frees its current owned object (if there is any and it is different from aOther) before taking over the ownership of the object from aOther. This method correctly handles a self assignment (i.e., assigning the pointer to itself).
| [in] | aOther | An rvalue reference to an OwnedPtr to move from. |
OwnedPtr. References OwnedPtr< Type >::OwnedPtr(), and OwnedPtr< Type >::Reset().
|
inlineprivate |
References Ptr< Type >::mPointer.
Referenced by OwnedPtr< Type >::Free(), OwnedPtr< Type >::Reset(), and OwnedPtr< Type >::~OwnedPtr().