Asposecpplib
System::DynamicWeakPtr< T, trunkMode, weakLeafs > Class Template Reference

Smart pointer class which tracks pointer modes of template arguments of stored object and updates them after each assignment. This type is a pointer to manage other object's deletion. It should be allocated on stack and passed to functions either by value or by const reference. More...

Inherits System::SmartPtr< T >.

Classes

class  Reference
 Reference class which ensures that DynamicWeakPtr::Apply is called. Used if DynamicWeakPtr is passed as SmartPtr reference parameter to function which may assign to it. More...
 

Public Types

typedef SmartPtr< T > SmartPtr_
 SmartPtr baseclass alias. More...
 
typedef DynamicWeakPtr< T, trunkMode, weakLeafs... > DynamicWeakPtr_
 Self type alias. More...
 
typedef T Pointee_
 Pointed type. More...
 
- Public Types inherited from System::SmartPtr< T >
typedef T Pointee_
 Pointed type. More...
 
typedef SmartPtr< T > SmartPtr_
 Specialized smart pointer type. More...
 
typedef System::Details::ArrayTypeResolver< T >::type ArrayType
 Same as Pointee_, if it is a specialization of System::Array, and void otherwise. More...
 
using ValueType = typename System::Details::SelectType< typename System::Details::ArrayTypeResolver< T >::value_type >::type
 Storage type of pointed array. Only meaningful if T is a specialization of System::Array. More...
 

Public Member Functions

 DynamicWeakPtr (std::nullptr_t=nullptr)
 Creates null smart pointer. More...
 
 DynamicWeakPtr (Pointee_ *object)
 Creates smart pointer pointing to given object. More...
 
 DynamicWeakPtr (const SmartPtr_ &ptr)
 Copy-constructs smart pointer. More...
 
template<class Q >
 DynamicWeakPtr (const SmartPtr< Q > &x)
 Copy-constructs smart pointer. More...
 
 DynamicWeakPtr (const DynamicWeakPtr_ &ptr)
 Copy-constructs smart pointer. More...
 
 DynamicWeakPtr (SmartPtr_ &&x)
 Move-constructs smart pointer. More...
 
bool operator== (std::nullptr_t) const
 Checks if smart pointer is null. More...
 
DynamicWeakPtr_operator= (SmartPtr_ &&x)
 Move-assigns smart pointer. More...
 
DynamicWeakPtr_operator= (const SmartPtr_ &x)
 Copy-assigns smart pointer. More...
 
template<typename Q >
DynamicWeakPtr_operator= (const SmartPtr< Q > &x)
 Copy-assigns smart pointer. More...
 
DynamicWeakPtr_operator= (typename SmartPtr_::Pointee_ *p)
 Assigns smart pointer. More...
 
DynamicWeakPtr_operator= (std::nullptr_t)
 Sets smart pointer to null. More...
 
- Public Member Functions inherited from System::SmartPtr< T >
 SmartPtr (SmartPtrMode mode)
 Creates SmartPtr object of required mode. More...
 
 SmartPtr (std::nullptr_t=nullptr, SmartPtrMode mode=SmartPtrMode::Shared)
 Creates null-pointer SmartPtr object of required mode. More...
 
 SmartPtr (Pointee_ *object, SmartPtrMode mode=SmartPtrMode::Shared)
 Creates SmartPtr pointing to specified object, or converts raw pointer to SmartPtr. More...
 
 SmartPtr (const SmartPtr_ &ptr, SmartPtrMode mode=SmartPtrMode::Shared)
 Copy constructs SmartPtr object. Both pointers point to the same object afterwards. More...
 
template<class Q , typename = typename std::enable_if<std::is_convertible<Q*, Pointee_*>::value>::type>
 SmartPtr (const SmartPtr< Q > &x, SmartPtrMode mode=SmartPtrMode::Shared)
 Copy constructs SmartPtr object. Both pointers point to the same object afterwards. Performs type conversion if allowed. More...
 
 SmartPtr (SmartPtr_ &&x, SmartPtrMode mode=SmartPtrMode::Shared) noexcept
 Move constructs SmartPtr object. Effectively, swaps two pointers, if they are both of same mode. x may be unusable after call. More...
 
template<typename Y >
 SmartPtr (const SmartPtr< Array< Y >> &src, SmartPtrMode mode=SmartPtrMode::Shared)
 Converts type of referenced array by creating a new array of different type. Useful if in C# there is an array type cast which is unsupported in C++. More...
 
template<typename Y , typename = typename std::enable_if<std::is_same<Y, EmptyArrayInitializer>::value, void>::type>
 SmartPtr (const Y &)
 Initializes empty array. Used to port some C# code constructs. More...
 
template<typename P >
 SmartPtr (const SmartPtr< P > &ptr, Pointee_ *p, SmartPtrMode mode=SmartPtrMode::Shared)
 Constructs a SmartPtr which shares ownership information with the initial value of ptr, but holds an unrelated and unmanaged pointer p. More...
 
 ~SmartPtr ()
 Destroys SmartPtr object. If required, decreases pointed object's reference counter and deletes object. More...
 
SmartPtr_operator= (SmartPtr_ &&x) noexcept
 Move-assigns SmartPtr object. x becomes unusable. More...
 
SmartPtr_operator= (const SmartPtr_ &x)
 Copy-assigns SmartPtr object. More...
 
template<typename Q >
SmartPtr_operator= (const SmartPtr< Q > &x)
 Copy-assigns SmartPtr object. Does required type conversions. More...
 
SmartPtr_operator= (Pointee_ *p)
 Assigns raw pointer to SmartPtr object. More...
 
SmartPtr_operator= (std::nullptr_t)
 Sets pointer value to nullptr. More...
 
Pointee_operator-> () const
 Allows to access members of referenced object. More...
 
bool operator== (std::nullptr_t) const
 Checks if pointer points to nullptr. More...
 
Pointee_get () const
 Gets pointed object. More...
 
Pointee_get_shared () const
 Gets pointed object, but asserts that pointer is in shared mode. More...
 
void reset (Pointee_ *ptr)
 Sets pointed object. More...
 
void reset ()
 Makes pointer pointing to nullptr. More...
 
SmartPtrMode get_Mode () const
 Gets pointer mode. More...
 
bool IsShared () const
 Checks if pointer is in shared mode. More...
 
bool IsWeak () const
 Checks if pointer is in weak mode. More...
 
void set_Mode (SmartPtrMode mode)
 Sets pointer mode. May alter referenced object's reference counts. More...
 
Pointee_operator* () const
 Gets reference to pointed object. Asserts that pointer is not null. More...
 
 operator bool () const noexcept
 Checks if pointer is not null. More...
 
bool operator! () const noexcept
 Checks if pointer is null. More...
 
template<class Y >
bool operator< (Y *p) const
 Provides less-compare semantics for SmartPtr class. More...
 
template<class Y >
bool operator< (SmartPtr< Y > const &x) const
 Provides less-compare semantics for SmartPtr class. More...
 
template<class Y >
SmartPtr< Y > static_pointer_cast () const
 Casts pointer to different type using static_cast on pointed object. More...
 
template<class Y >
SmartPtr< Y > dynamic_pointer_cast () const
 Casts pointer to different type using dynamic_cast on pointed object. More...
 
template<class Y >
SmartPtr< Y > const_pointer_cast () const
 Casts pointer to different type using const_cast on pointed object. More...
 
bool Is (const System::TypeInfo &target) const
 Checks if pointed object is of specific type or its child type. Follows C# 'is' semantics. More...
 
ObjectGetObjectOrNull () const
 Gets pointed object (if any) or nullptr. Same as get(). More...
 
SmartPtr< ObjectToObjectPtr () const
 Converts any pointer type to pointer to Object. Doesn't require Pointee_ type to be complete. More...
 
Pointee_GetPointer () const
 Gets pointed object (if any) or nullptr. Same as get(). More...
 
int get_shared_count () const
 Gets number of shared pointers existing to referenced object, including current one. Asserts current pointer being in shared mode. More...
 
void SetContainedTemplateWeakPtr (unsigned int argument) const
 Calls SetTemplateWeakPtr() method on pointed object (if any). More...
 
template<typename Q = T>
auto begin () noexcept -> decltype(std::declval< Q >().begin())
 Accessor for begin() method of an underling collection. Only compiles if SmartPtr_ is specialization type with begin() method. More...
 
template<typename Q = T>
auto end () noexcept -> decltype(std::declval< Q >().end())
 Accessor for end() method of an underling collection. Only compiles if SmartPtr_ is specialization type with end() method. More...
 
template<typename Q = T>
auto begin () const noexcept -> decltype(std::declval< const Q >().begin())
 Accessor for begin() method of an underling collection. Only compiles if SmartPtr_ is specialization type with begin() method. More...
 
template<typename Q = T>
auto end () const noexcept -> decltype(std::declval< const Q >().end())
 Accessor for end() method of an underling collection. Only compiles if SmartPtr_ is specialization type with end() method. More...
 
int GetHashCode () const
 Calls GetHashCode() on pointed object. More...
 
T * GetObjectNotNull () const
 Gets currently referenced object (if any) or throws. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from System::SmartPtr< T >
static const System::TypeInfoType ()
 Shortcut to get System::TypeInfo object for the Pointee_ type. More...
 
- Public Attributes inherited from System::SmartPtr< T >
template<typename IdxType >
decltype(System::Details::GetByIndex(std::declval< const SmartPtr_ * >(), std::declval< IdxType >()) operator[] )(IdxType idx) const
 Accessor for array elements. Only compiles if SmartPtr_ is specialization of System::Array. More...
 

Detailed Description

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
class System::DynamicWeakPtr< T, trunkMode, weakLeafs >

Smart pointer class which tracks pointer modes of template arguments of stored object and updates them after each assignment. This type is a pointer to manage other object's deletion. It should be allocated on stack and passed to functions either by value or by const reference.

Template Parameters
Pointeetype.
trunkModeMode of smart pointer itself, shared or weak.
weakLeafsIndexes of template arguments of stored type which should be set to weak pointer mode.

Member Typedef Documentation

◆ DynamicWeakPtr_

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
typedef DynamicWeakPtr<T, trunkMode, weakLeafs...> System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr_

Self type alias.

◆ Pointee_

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
typedef T System::SmartPtr< T >::Pointee_

Pointed type.

◆ SmartPtr_

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
typedef SmartPtr<T> System::DynamicWeakPtr< T, trunkMode, weakLeafs >::SmartPtr_

SmartPtr baseclass alias.

Constructor & Destructor Documentation

◆ DynamicWeakPtr() [1/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( std::nullptr_t  = nullptr)
inline

Creates null smart pointer.

◆ DynamicWeakPtr() [2/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( Pointee_ object)
inline

Creates smart pointer pointing to given object.

Parameters
objectPointee.

◆ DynamicWeakPtr() [3/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( const SmartPtr_ ptr)
inline

Copy-constructs smart pointer.

Parameters
ptrSmart pointer to copy pointee information from.

◆ DynamicWeakPtr() [4/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
template<class Q >
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( const SmartPtr< Q > &  x)
inline

Copy-constructs smart pointer.

Template Parameters
QSource pointer pointee type.
Parameters
xSmart pointer to copy pointee information from.

◆ DynamicWeakPtr() [5/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( const DynamicWeakPtr_ ptr)
inline

Copy-constructs smart pointer.

Parameters
ptrSmart pointer to copy pointee information from.

◆ DynamicWeakPtr() [6/6]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
System::DynamicWeakPtr< T, trunkMode, weakLeafs >::DynamicWeakPtr ( SmartPtr_ &&  x)
inline

Move-constructs smart pointer.

Parameters
xSmart pointer to move pointee information from. Becomes unusable after call.

Member Function Documentation

◆ operator=() [1/5]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
DynamicWeakPtr_& System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator= ( SmartPtr_ &&  x)
inline

Move-assigns smart pointer.

Parameters
xPointer to move-assign value from.
Returns
Self reference.

◆ operator=() [2/5]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
DynamicWeakPtr_& System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator= ( const SmartPtr_ x)
inline

Copy-assigns smart pointer.

Parameters
xPointer to copy-assign value from.
Returns
Self reference.

◆ operator=() [3/5]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
template<typename Q >
DynamicWeakPtr_& System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator= ( const SmartPtr< Q > &  x)
inline

Copy-assigns smart pointer.

Template Parameters
QSource pointee type.
Parameters
xPointer to copy-assign value from.
Returns
Self reference.

◆ operator=() [4/5]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
DynamicWeakPtr_& System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator= ( typename SmartPtr_::Pointee_ p)
inline

Assigns smart pointer.

Parameters
pPointer value.
Returns
Self reference.

◆ operator=() [5/5]

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
DynamicWeakPtr_& System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator= ( std::nullptr_t  )
inline

Sets smart pointer to null.

Returns
Self reference.

◆ operator==()

template<typename T, SmartPtrMode trunkMode, unsigned int ... weakLeafs>
bool System::DynamicWeakPtr< T, trunkMode, weakLeafs >::operator== ( std::nullptr_t  ) const
inline

Checks if smart pointer is null.

Returns
True if smart pointer is null and false otherwise.