PLaSK library

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
plask::HolderRef< T > Struct Template Reference

Template for base class of object holder. More...

`#include <plask/memory.hpp>`

Collaboration diagram for plask::HolderRef< T >:
[legend]

## Public Member Functions
| HolderRef ()
| HolderRef (T *held)
| Construct a holder with given `held` object.
bool | isNotNull () const
bool | isNull () const
void | reset (T *new_held)

## Protected Attributes
shared_ptr< T > | held
| Hold object. Typically can be nullptr only after move assignment.

## Detailed Description

template<typename T>
struct plask::HolderRef< T >

Template for base class of object holder.

It allow to hold polymorphic class inside one type and use reference counting to delete held object in proper time.

Typically, subclasses adds some delegates methods to held object. Hold object is stored by pointer, so it can store class derived from T. Stored object is deleted in destructor when last reference to it is lost.

Template Parameters

  T | type of class to hold

Definition at line 141 of file memory.hpp.

## Constructor & Destructor Documentation

## ◆ HolderRef() [1/2]

template<typename T >

plask::HolderRef< T >::HolderRef | ( |  | ) |
| inline

Definition at line 150 of file memory.hpp.

## ◆ HolderRef() [2/2]

template<typename T >

plask::HolderRef< T >::HolderRef | ( | T * | held | ) |
| inline

Construct a holder with given `held` object.

Parameters

  held | object to hold

Definition at line 156 of file memory.hpp.

## Member Function Documentation

## ◆ isNotNull()

template<typename T >

bool plask::HolderRef< T >::isNotNull | ( |  | ) | const
| inline

Definition at line 158 of file memory.hpp.

## ◆ isNull()

template<typename T >

bool plask::HolderRef< T >::isNull | ( |  | ) | const
| inline

Definition at line 160 of file memory.hpp.

## ◆ reset()

template<typename T >

void plask::HolderRef< T >::reset | ( | T * | new_held | ) |
| inline

Definition at line 162 of file memory.hpp.

## Member Data Documentation

## ◆ held

template<typename T >

shared_ptr<T> plask::HolderRef< T >::held
| protected

Hold object. Typically can be nullptr only after move assignment.

Definition at line 146 of file memory.hpp.

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

- plask/memory.hpp