| Face Engine SDK 5.32.0 A face detection, recognition and tracking engine.

Public Member Functions | List of all members
fsdk::Ref< T > Struct Template Reference

Smart pointer for reference counted objects. More...

`#include <Ref.h>`

Inheritance diagram for fsdk::Ref< T >:

## Public Member Functions
| Ref () noexcept=default
| Constructor. Initializes object pointer to nullptr.
| Ref (std::nullptr_t) noexcept
| Initializes object pointer to nullptr.
| Ref (T *ptr) noexcept
| Initializes object pointer with ptr and retains a reference. More...
| Ref (const Ref &other)
| Initializes object pointer with other and retains a reference. More...
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
| Ref (const Ref< D > &other)
| Initializes object pointer with other and retains a reference. More...
| Ref (Ref &&other) noexcept
| Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged. More...
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
| Ref (Ref< D > &&other) noexcept
| Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged. More...
| ~Ref () noexcept
| Releases reference being held (if any).
T * | operator-> () const noexcept
| Access pointer. More...
T ** | getInitReference () noexcept
| Access pointer for initialization. More...
bool | operator== (const Ref &other) const noexcept
| Check if two refs are the same. More...
bool | operator!= (const Ref &other) const noexcept
| Check if two refs are not the same. More...
Ref & | operator= (const Ref &other) noexcept
| Assign a strong reference. More...
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
Ref & | operator= (const Ref< D > &other) noexcept
| Assign a strong reference. More...
Ref & | operator= (Ref &&other) noexcept
| Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged. More...
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
Ref & | operator= (Ref< D > &&other) noexcept
| Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged. More...
Ref & | operator= (T *ptr) noexcept
| Assign a raw pointer. More...
Ref & | operator= (std::nullptr_t) noexcept
| Assign a nullptr_t. More...
Ref & | assign (T *ptr) noexcept
| Assign an object. Presumes shared ownership, increases reference count. More...
Ref & | acquire (T *ptr) noexcept
| Acquire ownership of the object. More...
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
Ref & | move (Ref< D > &&other) noexcept
| Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged. More...
Ref & | make_ref (T *ptr) noexcept
| Create ref without acquiring ownership. More...
T * | reset () noexcept
| Reset reference counted object and assign nullptr to the pointer.
template<typename S >
Ref< S > | as () const noexcept
| Make smart reference with relative type. More...
Public Member Functions inherited from fsdk::RefBase< T >
| RefBase () noexcept=default
| Initializes object pointer to nullptr.
| RefBase (T *ptr) noexcept
| Initializes object pointer with ptr. More...
| operator T* () const noexcept
| Get raw object pointer. More...
T & | operator* () const noexcept
| Dereference operator. More...
| operator bool () const noexcept
| Implicit cast to bool. More...
bool | operator== (const RefBase &other) const noexcept
| Check if two refs are the same. More...
bool | operator!= (const RefBase &other) const noexcept
| Check if two refs are not the same. More...
bool | isNull () const noexcept
| Check for nullptr. More...
bool | isExpired () const noexcept
| Check is object is dead. More...
bool | isUnique () const noexcept
| Check if object has only one strong reference. More...
T * | get () const noexcept
| Get current raw object pointer. More...
void | set (T *ptr) noexcept
| Replace object pointer without any checks or reference management. More...

## Additional Inherited Members
Protected Attributes inherited from fsdk::RefBase< T >
T * | m_ptr {nullptr}
| Raw pointer.

## Detailed Description

### template<typename T>
struct fsdk::Ref< T >

Smart pointer for reference counted objects.

Automatically calls retain/release and provides safety assertions.

Template Parameters

  T | object interface (must be derived from IRefCounted)

## Constructor & Destructor Documentation

## ◆ Ref() [1/5]

template<typename T>

fsdk::Ref< T >::Ref | ( | T * | ptr | ) |
| inline explicit noexcept

Initializes object pointer with ptr and retains a reference.

Note
  this shares ownership.

Parameters

  [in] | ptr | raw pointer to initialize with.

## ◆ Ref() [2/5]

template<typename T>

fsdk::Ref< T >::Ref | ( | const Ref< T > & | other | ) |
| inline

Initializes object pointer with other and retains a reference.

Note
  this shares ownership.

Parameters

  [in] | other | pointer to initialize with.

## ◆ Ref() [3/5]

template<typename T>
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>

fsdk::Ref< T >::Ref | ( | const Ref< D > & | other | ) |
| inline explicit

Initializes object pointer with other and retains a reference.

Note
  this shares ownership.

Parameters

  [in] | other | pointer of derived template class to initialize with.

## ◆ Ref() [4/5]

template<typename T>

fsdk::Ref< T >::Ref | ( | Ref< T > && | other | ) |
| inline noexcept

Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged.

Parameters

  other | [in] reference to move from.

## ◆ Ref() [5/5]

template<typename T>
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>

fsdk::Ref< T >::Ref | ( | Ref< D > && | other | ) |
| inline explicit noexcept

Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged.

Parameters

  other | [in] reference to move from.

## Member Function Documentation

## ◆ acquire()

template<typename T>

Ref& fsdk::Ref< T >::acquire | ( | T * | ptr | ) |
| inline noexcept

Acquire ownership of the object.

Parameters

  [in] | ptr | raw object pointer to acquire.

## ◆ as()

template<typename T>
template<typename S >

Ref<S> fsdk::Ref< T >::as | ( |  | ) | const
| inline noexcept

Make smart reference with relative type.

Template Parameters

  S | target interface (must be relative to T)

## ◆ assign()

template<typename T>

Ref& fsdk::Ref< T >::assign | ( | T * | ptr | ) |
| inline noexcept

Assign an object. Presumes shared ownership, increases reference count.

Parameters

  [in] | ptr | raw object pointer to assign.

## ◆ getInitReference()

template<typename T>

T** fsdk::Ref< T >::getInitReference | ( |  | ) |
| inline noexcept

Access pointer for initialization.

Note
  previously held pointer is released.

Returns
  pointer to pointer to object.

## ◆ make_ref()

template<typename T>

Ref& fsdk::Ref< T >::make_ref | ( | T * | ptr | ) |
| inline noexcept

Create ref without acquiring ownership.

Parameters

  [in] | ptr | raw object pointer.

## ◆ move()

template<typename T>
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>

Ref& fsdk::Ref< T >::move | ( | Ref< D > && | other | ) |
| inline noexcept

Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged.

Parameters

  other | [in] reference to move from.

Returns
  reference to this

## ◆ operator!=()

template<typename T>

bool fsdk::Ref< T >::operator!= | ( | const Ref< T > & | other | ) | const
| inline noexcept

Check if two refs are not the same.

Returns
  true if two refs are not the same.

Parameters

  [in] | other | ref to check against.

## ◆ operator->()

template<typename T>

T* fsdk::Ref< T >::operator-> | ( |  | ) | const
| inline noexcept

Access pointer.

Note
  pointer is checked for null in runtime.

Returns
  pointer to object.

## ◆ operator=() [1/6]

template<typename T>

Ref& fsdk::Ref< T >::operator= | ( | const Ref< T > & | other | ) |
| inline noexcept

Assign a strong reference.

Parameters

  [in] | other | strong reference.

Returns
  reference.

## ◆ operator=() [2/6]

template<typename T>
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>

Ref& fsdk::Ref< T >::operator= | ( | const Ref< D > & | other | ) |
| inline noexcept

Assign a strong reference.

Parameters

  [in] | other | strong reference of derived template class.

Returns
  reference.

## ◆ operator=() [3/6]

template<typename T>

Ref& fsdk::Ref< T >::operator= | ( | Ref< T > && | other | ) |
| inline noexcept

Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged.

Parameters

  other | [in] reference to move from.

Returns
  reference to this

## ◆ operator=() [4/6]

template<typename T>
template<class D , typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>

Ref& fsdk::Ref< T >::operator= | ( | Ref< D > && | other | ) |
| inline noexcept

Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource stays unchanged. This operation does not affect other Ref instances managing the same resource, if any, they continue to manage the resource with reference count unchanged.

Parameters

  other | [in] reference to move from.

Returns
  reference to this

## ◆ operator=() [5/6]

template<typename T>

Ref& fsdk::Ref< T >::operator= | ( | T * | ptr | ) |
| inline noexcept

Assign a raw pointer.

Note
  this shares ownership.

Parameters

  [in] | ptr | raw pointer.

Returns
  reference.

## ◆ operator=() [6/6]

template<typename T>

Ref& fsdk::Ref< T >::operator= | ( | std::nullptr_t |  | ) |
| inline noexcept

Assign a nullptr_t.

Note
  this releases previously held reference (if any).

Returns
  reference.

## ◆ operator==()

template<typename T>

bool fsdk::Ref< T >::operator== | ( | const Ref< T > & | other | ) | const
| inline noexcept

Check if two refs are the same.

Returns
  true if two refs are the same.

Parameters

  [in] | other | ref to check against.

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

- include/fsdk/Types/Ref.h