ORIGINAL
|
Base smart pointer with reference counting. More...
#include <autoPtr.h>
Public Member Functions | |
u_integer | strongRefs () const |
Get strong reference count. | |
u_integer | weakRefs () const |
Get weak reference count. | |
bool | exist () const |
Check active ownership. | |
bool | expired () const |
Check resource validity. | |
operator bool () const | |
Boolean conversion operator. | |
bool | operator! () const |
Logical NOT operator. | |
const TYPE * | get () const |
Get managed pointer const version. | |
TYPE * | get () |
Get managed pointer. | |
virtual const TYPE & | operator* () const |
Const dereference operator. | |
virtual const TYPE * | operator-> () const |
Const member access operator. | |
virtual const TYPE & | operator[] (u_integer index) const |
Const array access operator. | |
virtual TYPE & | operator* () |
Mutable dereference operator. | |
virtual TYPE * | operator-> () |
Mutable member access operator. | |
virtual TYPE & | operator[] (u_integer index) |
Mutable array access operator. | |
void | swap (autoPtr &other) noexcept |
Swaps the reference counters between two autoPtr instances. | |
integer | compareTo (const autoPtr &other) const override |
Compare reference counters. | |
std::string | className () const override |
Get class name string. | |
std::string | toString (bool enter) const override |
String representation formatter. | |
u_integer | toHash () const noexcept override |
Compute hash value for the pointer. | |
bool | equals (const autoPtr &other) const noexcept override |
Equality comparison. | |
~autoPtr () override | |
Destructor triggers reference cleanup. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE> | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE> | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE> | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE> | |
auto | formatString (TYPE *const &ptr) -> std::string |
![]() | |
virtual integer | compareTo (const DERIVED &other) const=0 |
Compares the current object with another of the same type. | |
bool | operator== (const DERIVED &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const DERIVED &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const DERIVED &other) const |
Checks if the current object is less than another. | |
bool | operator> (const DERIVED &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const DERIVED &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const DERIVED &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
virtual bool | equals (const DERIVED &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
Protected Member Functions | |
autoPtr (TYPE *p) | |
Construct from raw pointer. | |
void | setPtr (TYPE *p) |
Replace managed pointer. | |
void | addStrongRef () |
Increment strong reference count. | |
void | addWeakRef () |
Increment weak reference count. | |
void | removeStrongRef () |
Decrement strong reference count. | |
void | removeWeakRef () |
Decrement weak reference count. | |
void | destroyRefCnt () noexcept |
Destroy reference counter. | |
void | clean () noexcept |
Cleanup resources when expired. | |
Static Protected Member Functions | |
static refCount< TYPE, DELETER > * | newRefCount (TYPE *p=nullptr) |
Create new reference counter. | |
Protected Attributes | |
refCount< TYPE, DELETER > * | ref_count |
Reference counter object. | |
Friends | |
template<typename T, typename DER, typename DEL> | |
bool | operator== (const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null) |
Equality comparison with nullptr. | |
template<typename T, typename DER, typename DEL> | |
bool | operator!= (const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null) |
Inequality comparison with nullptr. | |
template<typename T, typename DER, typename DEL> | |
bool | operator== (const std::nullptr_t &null, const autoPtr< T, DER, DEL > &ptr) |
Equality comparison with nullptr (reversed operands) | |
template<typename T, typename DER, typename DEL> | |
bool | operator!= (const std::nullptr_t &null, const autoPtr< T, DER, DEL > &ptr) |
Inequality comparison with nullptr (reversed operands) | |
Additional Inherited Members | |
![]() | |
template<typename TYPE> | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion. | |
template<typename TYPE> | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting. | |
template<typename TYPE> | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage. | |
template<typename TYPE> | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
Base smart pointer with reference counting.
TYPE | Managed object type |
DERIVED | CRTP pattern parameter for inheritance |
DELETER | Custom deleter policy type |
Provides core resource management capabilities through:
Exception-safe operations
For string representation capabilities For comparison operations For hashing support
|
explicitprotected |
Construct from raw pointer.
p | Raw pointer to manage |
|
overridevirtual |
Get class name string.
Reimplemented from original::printable.
Reimplemented in original::ownerPtr< TYPE, DELETER >, original::refCntPtr< TYPE, DERIVED, DELETER >, original::refCntPtr< TYPE, strongPtr< TYPE, DELETER >, DELETER >, original::refCntPtr< TYPE, weakPtr< TYPE, DELETER >, DELETER >, original::strongPtr< TYPE, DELETER >, original::strongPtr< original::filter< TYPE > >, and original::weakPtr< TYPE, DELETER >.
|
override |
|
protectednoexcept |
Destroy reference counter.
|
overridenoexcept |
Equality comparison.
other | autoPtr to compare with |
bool original::autoPtr< TYPE, DERIVED, DELETER >::exist | ( | ) | const |
Check active ownership.
bool original::autoPtr< TYPE, DERIVED, DELETER >::expired | ( | ) | const |
Check resource validity.
TYPE * original::autoPtr< TYPE, DERIVED, DELETER >::get | ( | ) |
Get managed pointer.
nullPointerError | if no active references |
const TYPE * original::autoPtr< TYPE, DERIVED, DELETER >::get | ( | ) | const |
Get managed pointer const version.
nullPointerError | if no active references |
|
staticprotected |
Create new reference counter.
p | Pointer to manage (nullptr allowed) |
|
explicit |
Boolean conversion operator.
bool original::autoPtr< TYPE, DERIVED, DELETER >::operator! | ( | ) | const |
Logical NOT operator.
|
virtual |
Mutable dereference operator.
nullPointerError | if no managed object |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
virtual |
Const dereference operator.
nullPointerError | if no managed object |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
virtual |
Mutable member access operator.
nullPointerError | if no managed object |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
virtual |
Const member access operator.
nullPointerError | if no managed object |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
virtual |
Mutable array access operator.
index | Array index |
nullPointerError | if no managed array |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
virtual |
Const array access operator.
index | Array index |
nullPointerError | if no managed array |
Reimplemented in original::weakPtr< TYPE, DELETER >.
|
protected |
Replace managed pointer.
p | New pointer to manage |
nullPointerError | if no active references |
original::u_integer original::autoPtr< TYPE, DERIVED, DELETER >::strongRefs | ( | ) | const |
Get strong reference count.
|
noexcept |
|
nodiscardoverridevirtualnoexcept |
Compute hash value for the pointer.
Reimplemented from original::hashable< autoPtr< TYPE, DERIVED, DELETER > >.
|
overridevirtual |
String representation formatter.
enter | Add newline if true |
Reimplemented from original::printable.
Reimplemented in original::refCntPtr< TYPE, DERIVED, DELETER >, original::refCntPtr< TYPE, strongPtr< TYPE, DELETER >, DELETER >, and original::refCntPtr< TYPE, weakPtr< TYPE, DELETER >, DELETER >.
original::u_integer original::autoPtr< TYPE, DERIVED, DELETER >::weakRefs | ( | ) | const |
Get weak reference count.
|
friend |
Inequality comparison with nullptr.
T | Managed object type |
DER | CRTP derived class type |
DEL | Deleter policy type |
ptr | autoPtr to compare |
null | nullptr_t to compare against |
|
friend |
Inequality comparison with nullptr (reversed operands)
T | Managed object type |
DER | CRTP derived class type |
DEL | Deleter policy type |
ptr | autoPtr to compare |
null | nullptr_t to compare against |
|
friend |
|
friend |
Equality comparison with nullptr (reversed operands)
T | Managed object type |
DER | CRTP derived class type |
DEL | Deleter policy type |
ptr | autoPtr to compare |
null | nullptr_t to compare against |