Pyrogenesis trunk
Classes | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
CShaderParams< value_t > Class Template Reference

Represents a mapping of name strings to value, for use with CShaderDefines (values are strings) and CShaderUniforms (values are vec4s). More...

#include <ShaderDefines.h>

Collaboration diagram for CShaderParams< value_t >:
Collaboration graph
[legend]

Classes

struct  SItems
 
struct  SItemsHash
 

Public Member Functions

 CShaderParams ()
 Create an empty map of defines. More...
 
void Set (CStrIntern name, const value_t &value)
 Add a name and associated value to the map of parameters. More...
 
void SetMany (const CShaderParams &params)
 Add all the names and values from another set of parameters. More...
 
std::map< CStrIntern, value_t > GetMap () const
 Return a copy of the current name/value mapping. More...
 
size_t GetHash () const
 Return a hash of the current mapping. More...
 
bool operator< (const CShaderParams &b) const
 Compare with some arbitrary total order. More...
 
bool operator== (const CShaderParams &b) const
 Fast equality comparison. More...
 
bool operator!= (const CShaderParams &b) const
 Fast inequality comparison. More...
 

Protected Attributes

SItemsm_Items
 

Private Types

using InternedItems_t = std::unordered_map< SItems, std::shared_ptr< SItems >, SItemsHash >
 

Private Member Functions

 CShaderParams (SItems *items)
 

Static Private Member Functions

static SItemsGetInterned (const SItems &items)
 Returns a pointer to an SItems equal to items. More...
 
static CShaderParams CreateEmpty ()
 

Static Private Attributes

static InternedItems_t s_InternedItems
 
static CShaderParams s_Empty
 

Detailed Description

template<typename value_t>
class CShaderParams< value_t >

Represents a mapping of name strings to value, for use with CShaderDefines (values are strings) and CShaderUniforms (values are vec4s).

Stored as interned vectors of name-value pairs, to support high performance comparison operators.

Not thread-safe - must only be used from the main thread.

Member Typedef Documentation

◆ InternedItems_t

template<typename value_t >
using CShaderParams< value_t >::InternedItems_t = std::unordered_map<SItems, std::shared_ptr<SItems>, SItemsHash>
private

Constructor & Destructor Documentation

◆ CShaderParams() [1/2]

template<typename value_t >
CShaderParams< value_t >::CShaderParams

Create an empty map of defines.

◆ CShaderParams() [2/2]

template<typename value_t >
CShaderParams< value_t >::CShaderParams ( SItems items)
private

Member Function Documentation

◆ CreateEmpty()

template<typename value_t >
CShaderParams< value_t > CShaderParams< value_t >::CreateEmpty
staticprivate

◆ GetHash()

template<typename value_t >
size_t CShaderParams< value_t >::GetHash

Return a hash of the current mapping.

◆ GetInterned()

template<typename value_t >
CShaderParams< value_t >::SItems * CShaderParams< value_t >::GetInterned ( const SItems items)
staticprivate

Returns a pointer to an SItems equal to items.

The pointer will be valid forever, and the same pointer will be returned for any subsequent requests for an equal items list.

◆ GetMap()

template<typename value_t >
std::map< CStrIntern, value_t > CShaderParams< value_t >::GetMap

Return a copy of the current name/value mapping.

◆ operator!=()

template<typename value_t >
bool CShaderParams< value_t >::operator!= ( const CShaderParams< value_t > &  b) const
inline

Fast inequality comparison.

◆ operator<()

template<typename value_t >
bool CShaderParams< value_t >::operator< ( const CShaderParams< value_t > &  b) const
inline

Compare with some arbitrary total order.

The order may be different each time the application is run (it is based on interned memory addresses).

◆ operator==()

template<typename value_t >
bool CShaderParams< value_t >::operator== ( const CShaderParams< value_t > &  b) const
inline

Fast equality comparison.

◆ Set()

template<typename value_t >
void CShaderParams< value_t >::Set ( CStrIntern  name,
const value_t &  value 
)

Add a name and associated value to the map of parameters.

If the name is already defined, its value will be replaced.

◆ SetMany()

template<typename value_t >
void CShaderParams< value_t >::SetMany ( const CShaderParams< value_t > &  params)

Add all the names and values from another set of parameters.

If any name is already defined in this object, its value will be replaced.

Member Data Documentation

◆ m_Items

template<typename value_t >
SItems* CShaderParams< value_t >::m_Items
protected

◆ s_Empty

template<typename value_t >
CShaderParams CShaderParams< value_t >::s_Empty
staticprivate

◆ s_InternedItems

template<typename value_t >
InternedItems_t CShaderParams< value_t >::s_InternedItems
staticprivate

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