ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
original::strongPtr< TYPE, DELETER > Class Template Reference

Shared ownership smart pointer with strong references. More...

#include <refCntPtr.h>

Inheritance diagram for original::strongPtr< TYPE, DELETER >:
Inheritance graph
Collaboration diagram for original::strongPtr< TYPE, DELETER >:
Collaboration graph

Public Member Functions

 strongPtr (TYPE *p=std::nullptr_t{})
 Construct from raw pointer.
 
 strongPtr (const strongPtr &other)
 Copy constructor shares ownership.
 
strongPtroperator= (const strongPtr &other)
 Copy assignment shares ownership.
 
 strongPtr (strongPtr &&other) noexcept
 Move constructor transfers ownership.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
strongPtr< U, DELstaticCastTo ()
 Static cast to different pointer type.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<const U>>
strongPtr< const U, DELstaticCastTo () const
 Static cast to const pointer type.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
strongPtr< U, DELdynamicCastTo ()
 Dynamic cast to different pointer type.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<const U>>
strongPtr< const U, DELdynamicCastTo () const
 Dynamic cast to const pointer type.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
strongPtr< U, DELconstCastTo () const
 Const cast to remove/add const qualifier.
 
void reset () noexcept
 Resets the smart pointer and releases the managed object.
 
strongPtroperator= (strongPtr &&other) noexcept
 Move assignment transfers ownership.
 
std::string className () const override
 Get class identifier.
 
 ~strongPtr () override
 Destructor decreases strong references count.
 
- Public Member Functions inherited from original::refCntPtr< TYPE, strongPtr< TYPE, DELETER >, DELETER >
bool operator== (const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
 Equality comparison operator.
 
bool operator!= (const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
 Inequality comparison operator.
 
std::string toString (bool enter) const override
 Formatted string with reference info.
 
 ~refCntPtr () override=default
 Default destructor of refCntPtr.
 
- Public Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
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 TYPEget () const
 Get managed pointer const version.
 
TYPEget ()
 Get managed pointer.
 
virtual const TYPEoperator* () const
 Const dereference operator.
 
virtual const TYPEoperator-> () const
 Const member access operator.
 
virtual const TYPEoperator[] (u_integer index) const
 Const array access operator.
 
virtual TYPEoperator* ()
 Mutable dereference operator.
 
virtual TYPEoperator-> ()
 Mutable member access operator.
 
virtual TYPEoperator[] (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.
 
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.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const chartoCString (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
 
- Public Member Functions inherited from original::comparable< autoPtr< TYPE, DERIVED, DELETER > >
bool operator== (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is less than another.
 
bool operator> (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const autoPtr< TYPE, DERIVED, DELETER > &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.
 
- Public Member Functions inherited from original::hashable< autoPtr< TYPE, DERIVED, DELETER > >
virtual bool equals (const autoPtr< TYPE, DERIVED, DELETER > &other) const noexcept
 Compares two objects for equality.
 
virtual ~hashable ()=0
 Virtual destructor.
 

Friends

template<typename , typename >
class weakPtr
 
template<typename T , typename DEL , typename... Args>
strongPtr< T, DELmakeStrongPtr (Args &&... args)
 Creates a new strongPtr managing a shared object.
 
template<typename T , typename DEL , typename... Args>
strongPtr< T, DELmakeStrongPtrArray (u_integer size, Args &&... args)
 Creates a new strongPtr managing a shared array.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE >
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion with type-specific formatting.
 
template<Printable TYPE>
static std::string formatString (const TYPE &t)
 Specialization for types deriving from printable.
 
template<EnumType TYPE>
static std::string formatString (const TYPE &t)
 Specialization for enum types with type-safe formatting.
 
template<typename TYPE >
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting with null safety.
 
template<typename TYPE >
static const charformatCString (const TYPE &t)
 C-string cache for temporary usage with static storage.
 
template<typename TYPE >
static std::string formatEnum (const TYPE &t)
 Enum formatting utility with underlying value extraction.
 
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
 
- Protected Member Functions inherited from original::refCntPtr< TYPE, strongPtr< TYPE, DELETER >, DELETER >
 refCntPtr (TYPE *p=std::nullptr_t{})
 Construct from raw pointer.
 
- Protected Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
 autoPtr (TYPE *p)
 Construct from raw pointer.
 
void addStrongRef () const
 Increment strong reference count.
 
void addWeakRef () const
 Increment weak reference count.
 
void removeStrongRef () const
 Decrement strong reference count.
 
void removeWeakRef () const
 Decrement weak reference count.
 
TYPEreleasePtr () noexcept
 Release ownership of the managed pointer.
 
void destroyRefCnt () noexcept
 Destroy reference counter.
 
void clean () noexcept
 Cleanup resources when expired.
 
- Static Protected Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
static refCount< TYPE, DELETER > * newRefCount (TYPE *p=nullptr)
 Create new reference counter.
 
- Protected Attributes inherited from original::autoPtr< TYPE, DERIVED, DELETER >
atomic< refCountBase * > ref_count
 Reference counter object.
 
TYPEalias_ptr
 Aliased pointer for type casting scenarios.
 

Detailed Description

template<typename TYPE, typename DELETER>
class original::strongPtr< TYPE, DELETER >

Shared ownership smart pointer with strong references.

Template Parameters
TYPEManaged object type
DELETERDeletion policy type (default: deleter<TYPE>)

Maintains object lifetime through reference counting:

Constructor & Destructor Documentation

◆ strongPtr() [1/3]

template<typename TYPE , typename DELETER >
original::strongPtr< TYPE, DELETER >::strongPtr ( TYPE p = std::nullptr_t{})
explicit

Construct from raw pointer.

Parameters
pPointer to manage
Warning
Shares ownership of existing resource

◆ strongPtr() [2/3]

template<typename TYPE , typename DELETER >
original::strongPtr< TYPE, DELETER >::strongPtr ( const strongPtr< TYPE, DELETER > &  other)

Copy constructor shares ownership.

Parameters
otherSource strongPtr to copy from

◆ strongPtr() [3/3]

template<typename TYPE , typename DELETER >
original::strongPtr< TYPE, DELETER >::strongPtr ( strongPtr< TYPE, DELETER > &&  other)
noexcept

Move constructor transfers ownership.

Parameters
otherSource strongPtr to move from
Postcondition
other becomes empty

Member Function Documentation

◆ className()

template<typename TYPE , typename DELETER >
std::string original::strongPtr< TYPE, DELETER >::className ( ) const
overridevirtual

Get class identifier.

Returns
Class name of strongPtr

Reimplemented from original::refCntPtr< TYPE, strongPtr< TYPE, DELETER >, DELETER >.

◆ constCastTo()

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
strongPtr< U, DEL > original::strongPtr< TYPE, DELETER >::constCastTo ( ) const

Const cast to remove/add const qualifier.

Template Parameters
UTarget type for const cast
DELRebound deleter type for target type
Returns
strongPtr<U, DEL> with const removed
Note
Uses const_cast for type conversion

◆ dynamicCastTo() [1/2]

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
strongPtr< U, DEL > original::strongPtr< TYPE, DELETER >::dynamicCastTo ( )

Dynamic cast to different pointer type.

Template Parameters
UTarget type for dynamic cast
DELRebound deleter type for target type
Returns
strongPtr<U, DEL> if cast succeeds, empty strongPtr otherwise
Note
Uses dynamic_cast for type conversion

◆ dynamicCastTo() [2/2]

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
strongPtr< const U, DEL > original::strongPtr< TYPE, DELETER >::dynamicCastTo ( ) const

Dynamic cast to const pointer type.

Template Parameters
UTarget type for dynamic cast
DELRebound deleter type for target type
Returns
strongPtr<const U, DEL> if cast succeeds, empty strongPtr otherwise
Note
Uses dynamic_cast for type conversion

◆ operator=() [1/2]

Copy assignment shares ownership.

Parameters
otherSource strongPtr to copy from
Returns
Reference to this strongPtr

◆ operator=() [2/2]

template<typename TYPE , typename DELETER >
strongPtr< TYPE, DELETER > & original::strongPtr< TYPE, DELETER >::operator= ( strongPtr< TYPE, DELETER > &&  other)
noexcept

Move assignment transfers ownership.

Parameters
otherSource strongPtr to move from
Returns
Reference to this strongPtr
Postcondition
other becomes empty

◆ reset()

template<typename TYPE , typename DELETER >
void original::strongPtr< TYPE, DELETER >::reset ( )
noexcept

Resets the smart pointer and releases the managed object.

Performs the following sequence of operations:

  1. Decrements the current strong reference count
  2. Cleans up the managed pointer and reference counter
  3. Creates a new reference counter and initializes strong references
    Postcondition
    Equivalent to replacing the current strongPtr with a newly constructed empty pointer

◆ staticCastTo() [1/2]

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
strongPtr< U, DEL > original::strongPtr< TYPE, DELETER >::staticCastTo ( )

Static cast to different pointer type.

Template Parameters
UTarget type for static cast
DELRebound deleter type for target type
Returns
strongPtr<U, DEL> with same reference counter
Note
Uses static_cast for type conversion

◆ staticCastTo() [2/2]

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
strongPtr< const U, DEL > original::strongPtr< TYPE, DELETER >::staticCastTo ( ) const

Static cast to const pointer type.

Template Parameters
UTarget type for static cast
DELRebound deleter type for target type
Returns
strongPtr<const U, DEL> with same reference counter
Note
Uses static_cast for type conversion

Friends And Related Symbol Documentation

◆ makeStrongPtr

template<typename TYPE , typename DELETER >
template<typename T , typename DEL , typename... Args>
strongPtr< T, DEL > makeStrongPtr ( Args &&...  args)
friend

Creates a new strongPtr managing a shared object.

Template Parameters
TType of object to create and manage
DELDeleter policy type (default: deleter<T>)
ArgsArgument types for object construction
Parameters
argsArguments to forward to T's constructor
Returns
strongPtr<T, DEL> sharing ownership of the new object
Note
Provides exception-safe object creation with shared ownership

The object will be destroyed when all strong references are released

// Create a strongPtr managing a new MyClass constructed with args
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37

◆ makeStrongPtrArray

template<typename TYPE , typename DELETER >
template<typename T , typename DEL , typename... Args>
strongPtr< T, DEL > makeStrongPtrArray ( u_integer  size,
Args &&...  args 
)
friend

Creates a new strongPtr managing a shared array.

Template Parameters
TType of array elements to create
DELDeleter policy type (default: deleter<T[]>)
ArgsArgument types for array element initialization
Parameters
sizeNumber of elements in the array
argsArguments to forward to each element's constructor
Returns
strongPtr<T, DEL> sharing ownership of the new array
Note
Provides exception-safe array creation with shared ownership

The array will be destroyed when all strong references are released

// Create a strongPtr managing a new MyClass[10] array

The documentation for this class was generated from the following file: