System::SmartPtr< T >::Data Class Reference

Internal data storage class which hides data members and enforces neccessary asserts around them. More...

Public Member Functions

 Data (SmartPtrMode mode)
 Initializes Data structure. Doesn't set any members except for m_mode. More...
 
 Data (const Data &)=delete
 
 Data (Data &&)=delete
 
Dataoperator= (const Data &)=delete
 
Dataoperator= (Data &&)=delete
 
SmartPtrMode GetMode () const
 Gets current pointer mode. More...
 
void SetMode (SmartPtrMode mode)
 Sets pointer mode. Doesn't do any reference count or pointer changes. More...
 
T * GetPointee () const
 Gets pointed object (if any) or nullptr. More...
 
T * GetComparable () const
 Gets pointed object (if set and not yet deleted) or nullptr. More...
 
bool IsNull () const
 Checks if referenced object is set and not yet deleted. More...
 
void SetNull ()
 Sets pointer to null. More...
 
bool HoldsReference () const
 Checks if pointer actually holds a shared or weak reference to an object. More...
 
Pointee_WeakGetPointee () const
 Gets referenced object. Asserts that pointer is weak. More...
 
System::Detail::SmartPtrCounter * WeakGetCounter () const
 Gets referenced object reference counter. Asserts that pointer is weak. Doesn't null-check. More...
 
System::Detail::SmartPtrCounter * WeakGetCounterOrNull () const
 Gets referenced object (if any) reference counter or null. Asserts that pointer is weak. More...
 
void WeakSetPointer (Pointee_ *pointee, System::Detail::SmartPtrCounter *counter)
 Sets pointer value. Asserts that pointer is weak. More...
 
Pointee_SharedGetPointee () const
 Gets referenced object. Asserts that pointer is shared. More...
 
ObjectSharedGetObject () const
 Gets referenced object which is cast to System::Object. Asserts that pointer is shared. Doesn't null-check. More...
 
ObjectSharedGetOwned () const
 Gets owned object which. Asserts that pointer is shared. Doesn't null-check. More...
 
ObjectSharedGetObjectOrNull () const
 Gets referenced object (if any) which is cast to System::Object or null. Asserts that pointer is shared. More...
 
ObjectSharedGetOwnedOrNull () const
 Gets owned object. Asserts that pointer is shared. More...
 
void ** SharedGetInternalPointer ()
 Gets pointer to internal pointer storage field. More...
 
void SharedSetPointer (Pointee_ *pointee, Object *object, Object *owned)
 Sets pointer value. Asserts that pointer is shared. More...
 
void SharedSetPointer (Pointee_ *pointee, Object *object)
 Sets pointer value. Asserts that pointer is shared. More...
 
void swap (Data &data) noexcept
 Swaps data of two Data instances, including modes and pointers. More...
 
void swapPointers (Data &data) noexcept
 Swaps pointer data of two Data instances, excluding modes. More...
 

Detailed Description

template<class T>
class System::SmartPtr< T >::Data

Internal data storage class which hides data members and enforces neccessary asserts around them.

Constructor & Destructor Documentation

◆ Data() [1/3]

template<class T>
System::SmartPtr< T >::Data::Data ( SmartPtrMode  mode)
inline

Initializes Data structure. Doesn't set any members except for m_mode.

◆ Data() [2/3]

template<class T>
System::SmartPtr< T >::Data::Data ( const Data )
delete

◆ Data() [3/3]

template<class T>
System::SmartPtr< T >::Data::Data ( Data &&  )
delete

Member Function Documentation

◆ GetComparable()

template<class T>
T* System::SmartPtr< T >::Data::GetComparable ( ) const
inline

Gets pointed object (if set and not yet deleted) or nullptr.

Returns
Referenced object (if set and not yet deleted) or nullptr (if pointer is weak and referenced object is already deleted).

◆ GetMode()

template<class T>
SmartPtrMode System::SmartPtr< T >::Data::GetMode ( ) const
inline

Gets current pointer mode.

Returns
Current pointer mode.

◆ GetPointee()

template<class T>
T* System::SmartPtr< T >::Data::GetPointee ( ) const
inline

Gets pointed object (if any) or nullptr.

Returns
Referenced object (if any) or nullptr.

◆ HoldsReference()

template<class T>
bool System::SmartPtr< T >::Data::HoldsReference ( ) const
inline

Checks if pointer actually holds a shared or weak reference to an object.

Returns
True if reference is being held, false otherwise.

◆ IsNull()

template<class T>
bool System::SmartPtr< T >::Data::IsNull ( ) const
inline

Checks if referenced object is set and not yet deleted.

Returns
False if referenced object is non-null and exists and false if pointer is null or pointer is weak and referenced object is already deleted.

◆ operator=() [1/2]

template<class T>
Data& System::SmartPtr< T >::Data::operator= ( const Data )
delete

◆ operator=() [2/2]

template<class T>
Data& System::SmartPtr< T >::Data::operator= ( Data &&  )
delete

◆ SetMode()

template<class T>
void System::SmartPtr< T >::Data::SetMode ( SmartPtrMode  mode)
inline

Sets pointer mode. Doesn't do any reference count or pointer changes.

Parameters
modeNew pointer mode.

◆ SetNull()

template<class T>
void System::SmartPtr< T >::Data::SetNull ( )
inline

Sets pointer to null.

◆ SharedGetInternalPointer()

template<class T>
void** System::SmartPtr< T >::Data::SharedGetInternalPointer ( )
inline

Gets pointer to internal pointer storage field.

Returns
Raw pointer to internal pointer storage field.

◆ SharedGetObject()

template<class T>
Object* System::SmartPtr< T >::Data::SharedGetObject ( ) const
inline

Gets referenced object which is cast to System::Object. Asserts that pointer is shared. Doesn't null-check.

Returns
Raw pointer to referenced object.

◆ SharedGetObjectOrNull()

template<class T>
Object* System::SmartPtr< T >::Data::SharedGetObjectOrNull ( ) const
inline

Gets referenced object (if any) which is cast to System::Object or null. Asserts that pointer is shared.

Returns
Raw pointer to referenced object (if any) or null.

◆ SharedGetOwned()

template<class T>
Object* System::SmartPtr< T >::Data::SharedGetOwned ( ) const
inline

Gets owned object which. Asserts that pointer is shared. Doesn't null-check.

Returns
Raw pointer to owned object.

◆ SharedGetOwnedOrNull()

template<class T>
Object* System::SmartPtr< T >::Data::SharedGetOwnedOrNull ( ) const
inline

Gets owned object. Asserts that pointer is shared.

Returns
Raw pointer to owned object (if any) or null.

◆ SharedGetPointee()

template<class T>
Pointee_* System::SmartPtr< T >::Data::SharedGetPointee ( ) const
inline

Gets referenced object. Asserts that pointer is shared.

Returns
Raw pointer to referenced object.

◆ SharedSetPointer() [1/2]

template<class T>
void System::SmartPtr< T >::Data::SharedSetPointer ( Pointee_ pointee,
Object object,
Object owned 
)
inline

Sets pointer value. Asserts that pointer is shared.

Parameters
pointeePointee object.
ownedOwned object cast to System::Object.
objectPointee object cast to System::Object.

◆ SharedSetPointer() [2/2]

template<class T>
void System::SmartPtr< T >::Data::SharedSetPointer ( Pointee_ pointee,
Object object 
)
inline

Sets pointer value. Asserts that pointer is shared.

Parameters
pointeePointee object.
objectPointee object cast to System::Object.

◆ swap()

template<class T>
void System::SmartPtr< T >::Data::swap ( Data data)
inlinenoexcept

Swaps data of two Data instances, including modes and pointers.

Parameters
dataData instance to swap data with.

◆ swapPointers()

template<class T>
void System::SmartPtr< T >::Data::swapPointers ( Data data)
inlinenoexcept

Swaps pointer data of two Data instances, excluding modes.

Parameters
dataData instance to swap data with.

◆ WeakGetCounter()

template<class T>
System::Detail::SmartPtrCounter* System::SmartPtr< T >::Data::WeakGetCounter ( ) const
inline

Gets referenced object reference counter. Asserts that pointer is weak. Doesn't null-check.

Returns
Raw pointer to reference counter.

◆ WeakGetCounterOrNull()

template<class T>
System::Detail::SmartPtrCounter* System::SmartPtr< T >::Data::WeakGetCounterOrNull ( ) const
inline

Gets referenced object (if any) reference counter or null. Asserts that pointer is weak.

Returns
Raw pointer to reference counter or null if pointer is null.

◆ WeakGetPointee()

template<class T>
Pointee_* System::SmartPtr< T >::Data::WeakGetPointee ( ) const
inline

Gets referenced object. Asserts that pointer is weak.

Returns
Raw pointer to referenced object.

◆ WeakSetPointer()

template<class T>
void System::SmartPtr< T >::Data::WeakSetPointer ( Pointee_ pointee,
System::Detail::SmartPtrCounter *  counter 
)
inline

Sets pointer value. Asserts that pointer is weak.

Parameters
pointeePointee object.
counterReference counter of pointee object.

Member Data Documentation

◆ m_counter

template<class T>
System::Detail::SmartPtrCounter* System::SmartPtr< T >::Data::m_counter

Reference counter structure linked to m_pointee.

◆ m_internal_pointer

template<class T>
void* System::SmartPtr< T >::Data::m_internal_pointer

Representation to make it possible setting m_pointee to nullptr without knowing its actual type.

◆ m_owned

template<class T>
Object* System::SmartPtr< T >::Data::m_owned

Owned pointer.

◆ m_pointee

template<class T>
Pointee_* System::SmartPtr< T >::Data::m_pointee

Referenced object.