ACF $AcfVersion:0$
Public Types | Public Member Functions | Static Public Member Functions | List of all members
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType > Class Template Reference

Shared ownership smart pointer for interface types. More...

#include <TInterfacePtr.h>

Inheritance diagram for istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >:
istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >

Public Types

typedef TInterfacePtr< InterfaceType, std::shared_ptr< RootIntefaceType > > BaseClass
 
typedef BaseClass::ExtractInterfaceFunc ExtractInterfaceFunc
 
- Public Types inherited from istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >
typedef PolymorphicPointerImpl RootObjectPtr
 
typedef std::function< InterfaceType *()> ExtractInterfaceFunc
 

Public Member Functions

 TSharedInterfacePtr () noexcept
 
 TSharedInterfacePtr (InterfaceType *interfacePtr) noexcept
 
 TSharedInterfacePtr (RootIntefaceType *rootPtr, const ExtractInterfaceFunc &extractInterface) noexcept
 
 TSharedInterfacePtr (const TSharedInterfacePtr &ptr) noexcept
 Copy constructor.
 
template<typename DerivedType >
 TSharedInterfacePtr (const TSharedInterfacePtr< DerivedType > &other) noexcept
 Copy constructor from derived type.
 
template<typename DerivedType >
 TSharedInterfacePtr (const std::shared_ptr< DerivedType > &ptr) noexcept
 
template<typename DerivedType >
 TSharedInterfacePtr (std::unique_ptr< DerivedType > &&ptr) noexcept
 
 TSharedInterfacePtr (TSharedInterfacePtr &&ptr) noexcept
 Move constructor.
 
template<typename DerivedType >
 TSharedInterfacePtr (TUniqueInterfacePtr< DerivedType > &&ptr) noexcept
 Construct from unique by transferring ownership into shared.
 
 ~TSharedInterfacePtr ()
 
void Reset () noexcept
 
TSharedInterfacePtroperator= (const TSharedInterfacePtr &ptr) noexcept
 Copy assignment operator.
 
template<typename DerivedType >
TSharedInterfacePtroperator= (const TSharedInterfacePtr< DerivedType > &ptr) noexcept
 Copy assignment operator from derived type.
 
TSharedInterfacePtroperator= (TSharedInterfacePtr &&ptr) noexcept
 
template<typename DerivedType >
TSharedInterfacePtrFromUnique (TUniqueInterfacePtr< DerivedType > &&uniquePtr) noexcept
 Convert from unique to shared.
 
TSharedInterfacePtrFromUnique (TUniqueInterfacePtr< InterfaceType > &uniquePtr) noexcept
 
template<class SourceInterfaceType >
bool MoveCastedPtr (TUniqueInterfacePtr< SourceInterfaceType > &&source) noexcept
 Move-cast from unique: transfer ownership if dynamic_cast succeeds.
 
template<class SourceInterfaceType >
bool MoveCastedPtr (TUniqueInterfacePtr< SourceInterfaceType > &source) noexcept
 
template<class SourceInterfaceType >
bool SetCastedPtr (TSharedInterfacePtr< SourceInterfaceType > &source) noexcept
 Set from another shared pointer if dynamic_cast succeeds.
 
template<class T >
TSharedInterfacePtr< T > dynamicCast () noexcept
 
template<class T >
TSharedInterfacePtr< const T > dynamicCast () const noexcept
 
- Public Member Functions inherited from istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >
bool IsValid () const noexcept
 
template<typename Interface = InterfaceType>
Interface * GetPtr () noexcept
 
template<typename Interface = InterfaceType>
const Interface * GetPtr () const noexcept
 
const InterfaceType * operator-> () const noexcept
 
InterfaceType * operator-> () noexcept
 
const InterfaceType & operator* () const noexcept
 
InterfaceType & operator* () noexcept
 
void Reset () noexcept
 
void SetPtr (InterfaceType *interfacePtr)
 
void SetPtr (istd::IPolymorphic *rootPtr, const ExtractInterfaceFunc &extractInterface)
 
void SetPtr (istd::IPolymorphic *rootPtr, InterfaceType *interfacePtr) noexcept
 
RootObjectPtrGetBasePtr () noexcept
 
const RootObjectPtrGetBasePtr () const noexcept
 
InterfaceType * get () noexcept
 
const InterfaceType * get () const noexcept
 
 operator bool () const noexcept
 
bool operator== (std::nullptr_t) const noexcept
 
bool operator!= (std::nullptr_t) const noexcept
 
TInterfacePtroperator= (std::nullptr_t) noexcept
 

Static Public Member Functions

template<typename OtherInterface >
static TSharedInterfacePtr CreateFromUnique (TUniqueInterfacePtr< OtherInterface > &uniquePtr) noexcept
 Create a shared pointer from unique pointer of other type by transferring ownership if dynamic_cast succeeds.
 
static TSharedInterfacePtr CreateFromUnique (TUniqueInterfacePtr< InterfaceType > &&uniquePtr) noexcept
 Create a shared pointer from unique of the same type by transferring ownership.
 
static TSharedInterfacePtr CreateFromUnique (TUniqueInterfacePtr< InterfaceType > &uniquePtr) noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >
 TInterfacePtr (const TInterfacePtr &)=delete
 
TInterfacePtroperator= (const TInterfacePtr &)=delete
 
 TInterfacePtr () noexcept
 
 TInterfacePtr (InterfaceType *interfacePtr) noexcept
 
 TInterfacePtr (std::nullptr_t) noexcept
 
 TInterfacePtr (istd::IPolymorphic *rootPtr, const ExtractInterfaceFunc &extractInterface) noexcept
 
 TInterfacePtr (istd::IPolymorphic *rootPtr, InterfaceType *interfacePtr) noexcept
 
 TInterfacePtr (TInterfacePtr &&ptr) noexcept
 
TInterfacePtroperator= (TInterfacePtr &&ptr) noexcept
 
- Protected Attributes inherited from istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >
RootObjectPtr m_rootPtr
 
InterfaceType * m_interfacePtr = nullptr
 

Detailed Description

template<class InterfaceType, class RootIntefaceType = istd::IPolymorphic>
class istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >

Shared ownership smart pointer for interface types.

TSharedInterfacePtr provides shared ownership of an object with reference counting and automatic memory management. It is similar to std::shared_ptr but specialized for ACF's interface-based architecture where the root object and interface pointer may differ.

Key characteristics:

Template Parameters
InterfaceTypeThe interface type to expose.
RootIntefaceTypeThe root type that owns the object (default: istd::IPolymorphic).
Note
RootIntefaceType must derive from istd::IPolymorphic and have a virtual destructor.
See also
TUniqueInterfacePtr, TOptInterfacePtr

Example:

// Create a shared pointer
ptr1->DoSomething();
// Share ownership via copy
// Both ptr1 and ptr2 now own the object
// Object will be deleted when both go out of scope
Shared ownership smart pointer for interface types.

Definition at line 506 of file TInterfacePtr.h.

Member Typedef Documentation

◆ BaseClass

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
typedef TInterfacePtr<InterfaceType, std::shared_ptr<RootIntefaceType> > istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::BaseClass

Definition at line 509 of file TInterfacePtr.h.

◆ ExtractInterfaceFunc

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
typedef BaseClass::ExtractInterfaceFunc istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::ExtractInterfaceFunc

Definition at line 510 of file TInterfacePtr.h.

Constructor & Destructor Documentation

◆ TSharedInterfacePtr() [1/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( )
inlinenoexcept

Definition at line 517 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [2/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( InterfaceType *  interfacePtr)
inlinenoexcept

Definition at line 522 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [3/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( RootIntefaceType *  rootPtr,
const ExtractInterfaceFunc extractInterface 
)
inlinenoexcept

Definition at line 527 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [4/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( const TSharedInterfacePtr< InterfaceType, RootIntefaceType > &  ptr)
inlinenoexcept

Copy constructor.

Shares ownership.

Definition at line 535 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [5/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( const TSharedInterfacePtr< DerivedType > &  other)
inlinenoexcept

Copy constructor from derived type.

Shares ownership.

Definition at line 545 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [6/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( const std::shared_ptr< DerivedType > &  ptr)
inlinenoexcept

Definition at line 553 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [7/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( std::unique_ptr< DerivedType > &&  ptr)
inlinenoexcept

Definition at line 562 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [8/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( TSharedInterfacePtr< InterfaceType, RootIntefaceType > &&  ptr)
inlinenoexcept

Move constructor.

Transfers ownership.

Definition at line 573 of file TInterfacePtr.h.

◆ TSharedInterfacePtr() [9/9]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::TSharedInterfacePtr ( TUniqueInterfacePtr< DerivedType > &&  ptr)
inlinenoexcept

Construct from unique by transferring ownership into shared.

Definition at line 583 of file TInterfacePtr.h.

References istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::FromUnique().

◆ ~TSharedInterfacePtr()

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::~TSharedInterfacePtr ( )
inline

Member Function Documentation

◆ CreateFromUnique() [1/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
static TSharedInterfacePtr istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::CreateFromUnique ( TUniqueInterfacePtr< InterfaceType > &&  uniquePtr)
inlinestaticnoexcept

Create a shared pointer from unique of the same type by transferring ownership.

Alternatively move assignment operator can be used.

Definition at line 687 of file TInterfacePtr.h.

References istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::FromUnique().

◆ CreateFromUnique() [2/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
static TSharedInterfacePtr istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::CreateFromUnique ( TUniqueInterfacePtr< InterfaceType > &  uniquePtr)
inlinestaticnoexcept

◆ CreateFromUnique() [3/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename OtherInterface >
static TSharedInterfacePtr istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::CreateFromUnique ( TUniqueInterfacePtr< OtherInterface > &  uniquePtr)
inlinestaticnoexcept

Create a shared pointer from unique pointer of other type by transferring ownership if dynamic_cast succeeds.

Definition at line 665 of file TInterfacePtr.h.

Referenced by istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::CreateFromUnique(), istd::TOptInterfacePtr< InterfaceType >::TakeOver(), and istd::TOptInterfacePtr< InterfaceType >::TakeOver().

◆ dynamicCast() [1/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<class T >
TSharedInterfacePtr< const T > istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::dynamicCast ( ) const
inlinenoexcept

◆ dynamicCast() [2/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<class T >
TSharedInterfacePtr< T > istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::dynamicCast ( )
inlinenoexcept

◆ FromUnique() [1/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
TSharedInterfacePtr & istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::FromUnique ( TUniqueInterfacePtr< DerivedType > &&  uniquePtr)
inlinenoexcept

◆ FromUnique() [2/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
TSharedInterfacePtr & istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::FromUnique ( TUniqueInterfacePtr< InterfaceType > &  uniquePtr)
inlinenoexcept

◆ MoveCastedPtr() [1/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<class SourceInterfaceType >
bool istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::MoveCastedPtr ( TUniqueInterfacePtr< SourceInterfaceType > &&  source)
inlinenoexcept

Move-cast from unique: transfer ownership if dynamic_cast succeeds.

Definition at line 703 of file TInterfacePtr.h.

References istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::Reset().

Referenced by istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::MoveCastedPtr().

◆ MoveCastedPtr() [2/2]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<class SourceInterfaceType >
bool istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::MoveCastedPtr ( TUniqueInterfacePtr< SourceInterfaceType > &  source)
inlinenoexcept

◆ operator=() [1/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
TSharedInterfacePtr & istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::operator= ( const TSharedInterfacePtr< InterfaceType, RootIntefaceType > &  ptr)
inlinenoexcept

Copy assignment operator.

Shares ownership.

Definition at line 602 of file TInterfacePtr.h.

References istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >::m_rootPtr.

◆ operator=() [2/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<typename DerivedType >
TSharedInterfacePtr & istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::operator= ( const TSharedInterfacePtr< DerivedType > &  ptr)
inlinenoexcept

Copy assignment operator from derived type.

Shares ownership.

Definition at line 613 of file TInterfacePtr.h.

References istd::TInterfacePtr< InterfaceType, PolymorphicPointerImpl >::GetBasePtr().

◆ operator=() [3/3]

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
TSharedInterfacePtr & istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::operator= ( TSharedInterfacePtr< InterfaceType, RootIntefaceType > &&  ptr)
inlinenoexcept

Definition at line 621 of file TInterfacePtr.h.

◆ Reset()

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
void istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::Reset ( )
inlinenoexcept

◆ SetCastedPtr()

template<class InterfaceType , class RootIntefaceType = istd::IPolymorphic>
template<class SourceInterfaceType >
bool istd::TSharedInterfacePtr< InterfaceType, RootIntefaceType >::SetCastedPtr ( TSharedInterfacePtr< SourceInterfaceType > &  source)
inlinenoexcept

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