Item identifier in the LinearPool with usage counter.
More...
#include <linear-pool.hpp>
|
constexpr | Ref (ID< T > item) |
| Creates a new item reference. (Allocates counter)
|
|
| ~Ref () |
| Destroys item reference. (Decrements or deallocates counter)
|
|
| Ref (const Ref &ref) noexcept |
|
| Ref (Ref &&ref) noexcept |
|
Ref & | operator= (const Ref &ref) noexcept |
|
Ref & | operator= (Ref &&ref) noexcept |
|
int64_t | getRefCount () const noexcept |
| Returns current item reference count.
|
|
bool | isLastRef () const noexcept |
| Returns true if this is last item reference.
|
|
constexpr bool | operator== (const Ref &v) const noexcept |
| Returns true if this reference item is equal to the v reference item.
|
|
constexpr bool | operator!= (const Ref &v) const noexcept |
| Returns true if this reference item is not equal to the v reference item.
|
|
constexpr bool | operator< (const Ref &v) const noexcept |
| Returns true if this reference item is less than the v reference item.
|
|
constexpr | operator ID< T > () const noexcept |
| Returns reference item ID.
|
|
constexpr | operator bool () const noexcept |
| Returns true if reference item is not null.
|
|
uint32_t | operator* () const noexcept |
| Returns reference item index + 1 in the linear pool.
|
|
template<typename T>
struct ecsm::Ref< T >
Item identifier in the LinearPool with usage counter.
- Template Parameters
-
T | type of the item in the linear pool |
Useful in cases where we need to track item usage in the program and destroy it when it's not needed anymore.
◆ Ref()
template<typename T >
constexpr Ref |
( |
ID< T > | item | ) |
|
|
inlineexplicitconstexpr |
Creates a new item reference. (Allocates counter)
- Parameters
-
- Template Parameters
-
T | type of the item in the linear pool |
◆ operator==()
template<typename T >
constexpr bool operator== |
( |
const Ref< T > & | v | ) |
const |
|
inlineconstexprnoexcept |
Returns true if this reference item is equal to the v reference item.
- Parameters
-
◆ operator!=()
template<typename T >
constexpr bool operator!= |
( |
const Ref< T > & | v | ) |
const |
|
inlineconstexprnoexcept |
Returns true if this reference item is not equal to the v reference item.
- Parameters
-
◆ operator<()
template<typename T >
constexpr bool operator< |
( |
const Ref< T > & | v | ) |
const |
|
inlineconstexprnoexcept |
Returns true if this reference item is less than the v reference item.
- Parameters
-
◆ operator ID< T >()
template<typename T >
constexpr operator ID< T > |
( |
| ) |
const |
|
inlineexplicitconstexprnoexcept |
Returns reference item ID.
- Template Parameters
-
T | type of the item in the linear pool |