Samchon Framework for CPP
1.0.0
|
Global shared pointer
.
More...
#include <SmartPointer.hpp>
Public Member Functions | |
SmartPointer () | |
Default Constructor. More... | |
SmartPointer (const _Ty *ptr) | |
Constrct from pointer. More... | |
SmartPointer (const SmartPointer &smartPointer) | |
Copy Constructor. More... | |
SmartPointer (SmartPointer &&smartPointer) | |
Move constructor. More... | |
~SmartPointer () | |
Destroy SmartPointer. More... | |
void | reset (const _Ty *ptr) |
Reset pointer. More... | |
auto | get () const -> _Ty * |
Get pointer. More... | |
auto | operator-> () const -> _Ty * |
Dereference object membr. More... | |
auto | operator* () const -> _Ty & |
Dereference object. More... | |
Private Attributes | |
_Ty * | ptr |
A pointer managed by SmartPointer. More... | |
Static Private Attributes | |
static std::map< _Ty *, size_t > | useCountMap |
TreeMap of use count of each pointer. More... | |
static std::mutex | mtx |
Mutex assigned to useCountMap. More... | |
Global shared pointer
.
SmartPointer is a global shared pointer based on map, map referencing.
Manages the storage of a pointer, providing a limited garbage-collection facility, possibly sharing that management with other objects.
Referenced comments of std::allocator.
The | type of managed object |
Definition at line 23 of file SmartPointer.hpp.
|
inline |
Default Constructor.
The object is empty (owns no pointer, use count of zero)
Definition at line 50 of file SmartPointer.hpp.
|
inlineexplicit |
Constrct from pointer.
The object owns ptr, setting the use count to add 1
ptr | The pointer to own |
Definition at line 61 of file SmartPointer.hpp.
References samchon::SmartPointer< _Ty >::reset().
|
inline |
Copy Constructor.
The object shares ownership of smartPointer's asset and increases the use count
smartPointer | The object to copy |
Definition at line 74 of file SmartPointer.hpp.
|
inline |
Move constructor.
The object acquires the content managed by smartPointer
The ceding object becomes empty and there's no change on use count
smartPointer | The object to move |
Definition at line 85 of file SmartPointer.hpp.
|
inline |
Destroy SmartPointer.
Destroys the object. But, before, it may produce the following side effects depending on the use_count of member
Definition at line 106 of file SmartPointer.hpp.
|
inline |
Reset pointer.
Reset pointer to manage and shrink use count of previous pointer.
Additionally, a call to this function has the same side effects as if SmartPointer's destructor was called before its value changed (including the deletion of the managed object if this SmartPointer was unique).
Pointer | whose ownership is taken over by the object. Unlike std::shared_ptr, ptr being managed by another SmartPointer does not cause any problem |
Definition at line 129 of file SmartPointer.hpp.
Referenced by samchon::SmartPointer< _Ty >::SmartPointer().
|
inline |
Get pointer.
Returns the stored pointer.
The stored pointer points to the object the shared_ptr object dereferences to, which is generally the same as its owned pointer.
Definition at line 155 of file SmartPointer.hpp.
References samchon::SmartPointer< _Ty >::ptr.
|
inline |
Dereference object membr.
Returns a pointer to the object pointed by the stored pointer in order to access one of its members. This member function shall not be called if the stored pointer is a null pointer.
It returns the same value as get().
Definition at line 171 of file SmartPointer.hpp.
|
inline |
Dereference object.
Returns a reference to the object pointerd by pointer. It is equivalent to: *get()
Definition at line 185 of file SmartPointer.hpp.
References samchon::SmartPointer< _Ty >::ptr.
|
staticprivate |
TreeMap of use count of each pointer.
Definition at line 29 of file SmartPointer.hpp.
|
staticprivate |
Mutex assigned to useCountMap.
Definition at line 34 of file SmartPointer.hpp.
|
private |
A pointer managed by SmartPointer.
Definition at line 40 of file SmartPointer.hpp.
Referenced by samchon::SmartPointer< _Ty >::get(), and samchon::SmartPointer< _Ty >::operator*().