Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::Handle< T, NamespaceType > Struct Template Reference

#include <Handle.h>


struct  NullType

Public Types

using IndexType = T

Public Member Functions

constexpr Handle (NullType)
constexpr Handle (T index)
template<typename U >
constexpr Handle (U index)
constexpr bool operator== (const Handle &rhs) const
constexpr bool operator!= (const Handle &rhs) const
constexpr bool operator< (const Handle &rhs) const
constexpr bool operator> (const Handle &rhs) const
constexpr bool operator<= (const Handle &rhs) const
void Reset ()
 Resets the handle to NullIndex.
constexpr T GetIndex () const
 Returns the index currently stored in the handle.
constexpr bool IsNull () const
 Returns whether the handle is equal to NullIndex.
constexpr bool IsValid () const
 Returns whether the handle is NOT equal to NullIndex.

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)

Public Attributes

m_index = NullIndex

Static Public Attributes

static const constexpr T NullIndex = T(-1)
static constexpr NullType Null {}

Detailed Description

template<typename T = uint32_t, typename NamespaceType = DefaultNamespaceType>
struct AZ::RHI::Handle< T, NamespaceType >

Handle a simple wrapper around an integral type, which adds the formal concept of a 'Null' value. It is designed to accommodate a zero-based 'index' where a value of 0 is considered valid. As such, the null value is equal to -1 casted to the type.

Template Parameters
TAn integral type held by the Handle container. A value of -1 (or max value for unsigned types) is reserved for the null index.
NamespaceTypeAn optional typename used to create a compile-time unique variant of Handle. This disallows trivial copying of unrelated 'types'. Useful to make a handle variant typed to a client class.

Sample Usage:

class Foo;
using FooHandle = Handle<uint16_t, Foo>;
FooHandle fooHandle;
class Bar;
using BarHandle = Handle<uint16_t, Bar>;
BarHandle barHandle;
fooHandle = barHandle; // Error! Different types!
fooHandle.IsNull(); // true
fooHandle.GetIndex(); // FooHandle::NullIndex
fooHandle = 15;
fooHandle.GetIndex(); // 15
fooHandle.IsNull(); // false
Definition: Handle.h:52
constexpr bool IsNull() const
Returns whether the handle is equal to NullIndex.
Definition: Handle.h:155

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