Open 3D Engine Atom Gem API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
AZ::RHI::Handle< T, NamespaceType > Struct Template Reference

#include <Handle.h>

Public Types

using IndexType = T
 

Public Member Functions

 Handle (T index)
 
template<typename U >
 Handle (U index)
 
bool operator== (const Handle &rhs) const
 
bool operator!= (const Handle &rhs) const
 
bool operator< (const Handle &rhs) const
 
bool operator> (const Handle &rhs) const
 
bool operator<= (const Handle &rhs) const
 
void Reset ()
 Resets the handle to NullIndex.
 
GetIndex () const
 Returns the index currently stored in the handle.
 
bool IsNull () const
 Returns whether the handle is equal to NullIndex.
 
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 T NullIndex = T(-1)
 
static const Handle 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

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