smart pointer class for opals objects More...
#include "SharedPtr.hpp"
Public Member Functions | |
SharedPtr (ObjectBase *obj) noexcept | |
Put an object that is derived from ObjectBase under the control of the smart pointer class. | |
SharedPtr (T *obj, void(*deleter)(void *)) noexcept | |
Put an object under the control of the smart pointer class with the corresponding deleter function pointer. | |
SharedPtr (const SharedPtr &ref) noexcept | |
SharedPtr & | operator= (const SharedPtr &h) |
void | reset () noexcept |
reset shared pointer and delete controlled object if necessary | |
void | reset (ObjectBase *obj) noexcept |
put a new ObjectBase object under the shared pointer control | |
void | reset (T *obj, void(*deleter)(void *)) noexcept |
put a new object under the shared pointer control (with the corresponding deleter function pointer) | |
void | swap (SharedPtr &h) noexcept |
T * | get () const noexcept |
get pointer to controlled object | |
const T & | operator* () const |
T & | operator* () |
const T * | operator-> () const |
T * | operator-> () |
unsigned int | use_count () const noexcept |
get number of SharedPtr instances that reference the same object | |
bool | unique () const noexcept |
is the controlled object only referenced by this SharedPtr instance | |
operator bool () const noexcept | |
T * | release () |
release the controlled object This is only possible if the controlled object is only referenced by the current SharedPtr instance. The user has to take care of deleting the object. | |
smart pointer class for opals objects
Smart pointers uses a reference counting mechanism to control the life time of an object. When the last SharePtr instance goes out of scope, the controlled object is deleted. In case an object is shared across dll boundaries, it is essential create and delete objects within the same heap. To do so you can either provide a corresponding delete function (only non-member functions are supported) or an object is derived from ObjectBase and the (overloaded) Delete function is called to delete the object.