Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::ResourceHolder::VectorField< T > Class Template Reference

A Field that holds a vector of up to some number of values. More...

#include "resourceholder.h"

Inheritance diagram for ion::gfx::ResourceHolder::VectorField< T >:
Collaboration diagram for ion::gfx::ResourceHolder::VectorField< T >:

Public Member Functions

 VectorField (const int change_bit_start, const size_t max_entries, ResourceHolder *holder)
 
 ~VectorField () override
 
void Add (const T &value)
 Adds a value to the vector. More...
 
void Remove (size_t i)
 Removes an element from the VectorField, replacing it with the last entry in the VectorField. More...
 
const TGet (const size_t i) const
 Gets a const reference to a value, if the index is valid, otherwise returns an InvalidReference. More...
 
TGetMutable (const size_t i)
 Gets a non-const pointer to a value and triggers the change. More...
 
bool Set (const size_t i, const T &value)
 If the index i is valid, sets the value at index i and tells the resource what has changed. More...
 
size_t GetCount () const
 
int GetBit () const
 Get the change bit. More...
 

Protected Member Functions

void OnChanged ()
 
void OnChanged (const int bit)
 Trigger a change for a specific bit. More...
 

Detailed Description

template<typename T>
class ion::gfx::ResourceHolder::VectorField< T >

A Field that holds a vector of up to some number of values.

The maximum is necessary for VectorFields that relate to GL state, such as Attributes; different platforms support different numbers of shader attributes, and this allows Ion to gracefully inform users (with an error message) if they try to add too many.

Definition at line 216 of file resourceholder.h.

Constructor & Destructor Documentation

template<typename T >
ion::gfx::ResourceHolder::VectorField< T >::VectorField ( const int  change_bit_start,
const size_t  max_entries,
ResourceHolder holder 
)
inline

Definition at line 218 of file resourceholder.h.

References DCHECK.

template<typename T >
ion::gfx::ResourceHolder::VectorField< T >::~VectorField ( )
inlineoverride

Definition at line 227 of file resourceholder.h.

Member Function Documentation

template<typename T >
void ion::gfx::ResourceHolder::VectorField< T >::Add ( const T value)
inline

Adds a value to the vector.

If too many Adds have occurred, then an error message is printed instead.

Definition at line 231 of file resourceholder.h.

References ion::port::ERROR, and LOG.

template<typename T >
const T& ion::gfx::ResourceHolder::VectorField< T >::Get ( const size_t  i) const
inline

Gets a const reference to a value, if the index is valid, otherwise returns an InvalidReference.

Definition at line 259 of file resourceholder.h.

int ion::gfx::ResourceHolder::FieldBase::GetBit ( ) const
inlineinherited

Get the change bit.

Definition at line 102 of file resourceholder.h.

template<typename T >
size_t ion::gfx::ResourceHolder::VectorField< T >::GetCount ( ) const
inline

Definition at line 295 of file resourceholder.h.

template<typename T >
T* ion::gfx::ResourceHolder::VectorField< T >::GetMutable ( const size_t  i)
inline

Gets a non-const pointer to a value and triggers the change.

Definition at line 269 of file resourceholder.h.

void ion::gfx::ResourceHolder::FieldBase::OnChanged ( )
inlineprotectedinherited

Definition at line 113 of file resourceholder.h.

void ion::gfx::ResourceHolder::FieldBase::OnChanged ( const int  bit)
inlineprotectedinherited

Trigger a change for a specific bit.

Definition at line 121 of file resourceholder.h.

template<typename T >
void ion::gfx::ResourceHolder::VectorField< T >::Remove ( size_t  i)
inline

Removes an element from the VectorField, replacing it with the last entry in the VectorField.

If there is only one entry in the VectorField then it is cleared. OnChanged() is called on the moved entry, as it may have changed before the call to Remove().

Definition at line 247 of file resourceholder.h.

template<typename T >
bool ion::gfx::ResourceHolder::VectorField< T >::Set ( const size_t  i,
const T value 
)
inline

If the index i is valid, sets the value at index i and tells the resource what has changed.

If the index is not valid, an error message is logged. Returns whether the set occurred.

Definition at line 282 of file resourceholder.h.

References value.


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