Raytrix Light Field SDK  4.0
Logo
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Rx::CKeyValueMap< TKey, TGroup > Class Template Reference

Detailed Description

template<typename TKey, typename TGroup>
class Rx::CKeyValueMap< TKey, TGroup >

A key value map class.

This class is able to map a key of a given data type to a value of one of six possible data types. A value is described by a value definition and has an initial value and a default value.

Template Parameters
TKeyThe data type of the key.
TGroupThe data type of the group.

Public Types

typedef std::map< TKey, SValueDef< TGroup > > TMapDefs
 
typedef void(* TParamSetCallback) (const TKey &tKey, void *pvContext)
 Defines an alias representing the callback function type of parameter-set-events. More...
 

Public Member Functions

 CKeyValueMap ()=default
 Default constructor. More...
 
 CKeyValueMap (const CKeyValueMap< TKey, TGroup > &xMap)
 Copy constructor. More...
 
 ~CKeyValueMap ()=default
 Destructor. More...
 
void Add (const TKey &tKey, const TGroup &tGroup, const CRxString &sxName, const CRxString &sxGUID, bool bRead, bool bWrite, bool bExtern, bool bExportable, EValueType::ID eType, Constraint::CAny *pxConstraint=nullptr)
 Adds tKey. More...
 
void Clear ()
 Clears this object to its blank/initial state. More...
 
std::vector< TKey > FilterByGroup (const TGroup &tGroup) const
 Get a list of all keys matching the given group. More...
 
template<class TValue >
const TValue & Get (const TKey &tKey) const
 
bool GetAsBool (const TKey &tKey) const
 
float GetAsFloat (const TKey &tKey) const
 
int GetAsInt (const TKey &tKey) const
 
std::set< TGroup > GetGroups () const
 Gets a set of all groups. More...
 
const TKey & GetKey (size_t nIdx) const
 Gets the key at the given index. More...
 
const SValueDef< TGroup > & GetValueDef (const TKey &tKey) const
 Gets the value definition of the given key. More...
 
const TMapDefsGetValueDefs () const
 Gets the value definitions. More...
 
template<class TValue >
void GetValueRange (const TKey &tKey, TValue &tMin, TValue &tMax) const
 Gets the value range of the value associated with the given key. More...
 
template<class TArray , class TValue >
void GetValueRange (const TKey &tKey, size_t &nArrayLenMin, size_t &nArrayLenMax, TValue &tMin, TValue &tMax) const
 Gets the value range of the value associated with the given key. More...
 
bool HasKey (const TKey &tKey) const
 Query if this map contains the given key. More...
 
bool IsKeyInGroup (const TKey &tKey, const TGroup &tGroup) const
 Query if the given key is in the given group. More...
 
bool IsReadable (const TKey &tKey) const
 Query if the value associated with the given key is readable. It must be flagged as readable and NOT extern. More...
 
template<class TValue >
bool IsValid (const TKey &tKey, const TValue &tValue) const
 Query if the given value is valid for the given key. This tests the data type and possible constraints. More...
 
bool IsWritable (const TKey &tKey) const
 Query if the value associated with the given key is writable. It must be flagged as writable and NOT extern. More...
 
CKeyValueMap< TKey, TGroup > & operator= (const CKeyValueMap< TKey, TGroup > &xMap)
 Assignment operator. More...
 
void ResetValue (const TKey &tKey, bool bResetToInitial=false)
 Sets the value associated with the given key to its initial or its default value. More...
 
template<class TValue >
void Set (const TKey &tKey, const TValue &tValue)
 
template<class TValue >
void SetAll (const TKey &tKey, const TValue &tDefault)
 
template<class TValue >
void SetDefault (const TKey &tKey, const TValue &tDefault)
 
void SetParamSetCallback (TParamSetCallback pxCallback, void *pvContext)
 Set the parameter set callback function. More...
 
size_t Size () const
 Gets the size of this map. More...
 
CRxString ToString (EValueType::ID eValueType) const
 Gets the string representation of the given value type. More...
 

Static Public Member Functions

template<class TValue >
static EValueType::ID GetValueType ()
 

Public Attributes

void * m_pvCallbackContext
 
TParamSetCallback m_pxCallback
 
std::map< TKey, SValue< CRxArrayDouble > > m_xMapArrayDouble
 
std::map< TKey, SValue< CRxArrayString > > m_xMapArrayString
 
std::map< TKey, SValue< CRxArrayUInt > > m_xMapArrayUInt
 
TMapDefs m_xMapDefs
 
std::map< TKey, SValue< double > > m_xMapDouble
 
std::map< TKey, SValue< CRxString > > m_xMapString
 
std::map< TKey, SValue< unsigned > > m_xMapUInt
 

Member Typedef Documentation

template<typename TKey, typename TGroup>
typedef std::map< TKey, SValueDef < TGroup > > Rx::CKeyValueMap< TKey, TGroup >::TMapDefs
template<typename TKey, typename TGroup>
typedef void(* Rx::CKeyValueMap< TKey, TGroup >::TParamSetCallback) (const TKey &tKey, void *pvContext)

Defines an alias representing the callback function type of parameter-set-events.

Constructor & Destructor Documentation

template<typename TKey, typename TGroup>
Rx::CKeyValueMap< TKey, TGroup >::CKeyValueMap ( )
default

Default constructor.

template<typename TKey, typename TGroup>
Rx::CKeyValueMap< TKey, TGroup >::CKeyValueMap ( const CKeyValueMap< TKey, TGroup > &  xMap)
inline

Copy constructor.

Parameters
xMapThe map to copy.
template<typename TKey, typename TGroup>
Rx::CKeyValueMap< TKey, TGroup >::~CKeyValueMap ( )
default

Destructor.

Member Function Documentation

template<typename TKey, typename TGroup>
void Rx::CKeyValueMap< TKey, TGroup >::Add ( const TKey &  tKey,
const TGroup &  tGroup,
const CRxString sxName,
const CRxString sxGUID,
bool  bRead,
bool  bWrite,
bool  bExtern,
bool  bExportable,
EValueType::ID  eType,
Constraint::CAny pxConstraint = nullptr 
)
inline

Adds tKey.

Parameters
tKeyThe key.
tGroupThe group.
sxNameName of the sx.
sxGUIDUnique identifier for the sx.
bReadtrue if the data was read.
bWritetrue to write.
bExterntrue to extern.
bExportabletrue if exportable.
eTypeThe type.
pxConstraint(Optional) the constraint.
template<typename TKey, typename TGroup>
void Rx::CKeyValueMap< TKey, TGroup >::Clear ( )
inline

Clears this object to its blank/initial state.

template<typename TKey, typename TGroup>
std::vector<TKey> Rx::CKeyValueMap< TKey, TGroup >::FilterByGroup ( const TGroup &  tGroup) const
inline

Get a list of all keys matching the given group.

Parameters
tGroupOnly return keys of this group.
Returns
A list of keys associated with the given group.
template<typename TKey, typename TGroup>
template<class TValue >
const TValue& Rx::CKeyValueMap< TKey, TGroup >::Get ( const TKey &  tKey) const
inline
template<typename TKey, typename TGroup>
bool Rx::CKeyValueMap< TKey, TGroup >::GetAsBool ( const TKey &  tKey) const
inline
template<typename TKey, typename TGroup>
float Rx::CKeyValueMap< TKey, TGroup >::GetAsFloat ( const TKey &  tKey) const
inline
template<typename TKey, typename TGroup>
int Rx::CKeyValueMap< TKey, TGroup >::GetAsInt ( const TKey &  tKey) const
inline
template<typename TKey, typename TGroup>
std::set<TGroup> Rx::CKeyValueMap< TKey, TGroup >::GetGroups ( ) const
inline

Gets a set of all groups.

Returns
The set of groups.
template<typename TKey, typename TGroup>
const TKey& Rx::CKeyValueMap< TKey, TGroup >::GetKey ( size_t  nIdx) const
inline

Gets the key at the given index.

Parameters
nIdxThe index.
Returns
The key.
template<typename TKey, typename TGroup>
const SValueDef<TGroup>& Rx::CKeyValueMap< TKey, TGroup >::GetValueDef ( const TKey &  tKey) const
inline

Gets the value definition of the given key.

Parameters
tKeyThe key.
Returns
The value definition.
template<typename TKey, typename TGroup>
const TMapDefs& Rx::CKeyValueMap< TKey, TGroup >::GetValueDefs ( ) const
inline

Gets the value definitions.

Returns
The value definitions.
template<typename TKey, typename TGroup>
template<class TValue >
void Rx::CKeyValueMap< TKey, TGroup >::GetValueRange ( const TKey &  tKey,
TValue &  tMin,
TValue &  tMax 
) const
inline

Gets the value range of the value associated with the given key.

Template Parameters
TValueThe data type of the value.
Parameters
tKeyThe key.
tMin[out] The minimum.
tMax[out] The maximum.
template<typename TKey, typename TGroup>
template<class TArray , class TValue >
void Rx::CKeyValueMap< TKey, TGroup >::GetValueRange ( const TKey &  tKey,
size_t &  nArrayLenMin,
size_t &  nArrayLenMax,
TValue &  tMin,
TValue &  tMax 
) const
inline

Gets the value range of the value associated with the given key.

Template Parameters
TArrayThe array type.
TValueThe data type of the value.
Parameters
tKeyThe key.
nArrayLenMin[out] The array length minimum.
nArrayLenMax[out] The array length maximum.
tMin[out] The minimum.
tMax[out] The maximum.
template<typename TKey, typename TGroup>
template<class TValue >
static EValueType::ID Rx::CKeyValueMap< TKey, TGroup >::GetValueType ( )
inlinestatic
template<typename TKey, typename TGroup>
bool Rx::CKeyValueMap< TKey, TGroup >::HasKey ( const TKey &  tKey) const
inline

Query if this map contains the given key.

Parameters
tKeyThe key to test for containment.
Returns
True if the key is in this map, false if not.
template<typename TKey, typename TGroup>
bool Rx::CKeyValueMap< TKey, TGroup >::IsKeyInGroup ( const TKey &  tKey,
const TGroup &  tGroup 
) const
inline

Query if the given key is in the given group.

Parameters
tKeyThe key.
tGroupThe group.
Returns
True if key is in given group, false if not.
template<typename TKey, typename TGroup>
bool Rx::CKeyValueMap< TKey, TGroup >::IsReadable ( const TKey &  tKey) const
inline

Query if the value associated with the given key is readable. It must be flagged as readable and NOT extern.

Parameters
tKeyThe key.
Returns
True if readable, false if not.
template<typename TKey, typename TGroup>
template<class TValue >
bool Rx::CKeyValueMap< TKey, TGroup >::IsValid ( const TKey &  tKey,
const TValue &  tValue 
) const
inline

Query if the given value is valid for the given key. This tests the data type and possible constraints.

Template Parameters
TValueThe data type of the value.
Parameters
tKeyThe key.
tValueThe value.
Returns
True if valid, false if not.
template<typename TKey, typename TGroup>
bool Rx::CKeyValueMap< TKey, TGroup >::IsWritable ( const TKey &  tKey) const
inline

Query if the value associated with the given key is writable. It must be flagged as writable and NOT extern.

Parameters
tKeyThe key.
Returns
True if writable, false if not.
template<typename TKey, typename TGroup>
CKeyValueMap<TKey, TGroup>& Rx::CKeyValueMap< TKey, TGroup >::operator= ( const CKeyValueMap< TKey, TGroup > &  xMap)
inline

Assignment operator.

Parameters
xMapThe map.
Returns
A shallow copy of this object.
template<typename TKey, typename TGroup>
void Rx::CKeyValueMap< TKey, TGroup >::ResetValue ( const TKey &  tKey,
bool  bResetToInitial = false 
)
inline

Sets the value associated with the given key to its initial or its default value.

Parameters
tKeyThe key.
bResetToInitial(Optional) True to reset to initial, false to reset to default.
template<typename TKey, typename TGroup>
template<class TValue >
void Rx::CKeyValueMap< TKey, TGroup >::Set ( const TKey &  tKey,
const TValue &  tValue 
)
inline
template<typename TKey, typename TGroup>
template<class TValue >
void Rx::CKeyValueMap< TKey, TGroup >::SetAll ( const TKey &  tKey,
const TValue &  tDefault 
)
inline
template<typename TKey, typename TGroup>
template<class TValue >
void Rx::CKeyValueMap< TKey, TGroup >::SetDefault ( const TKey &  tKey,
const TValue &  tDefault 
)
inline
template<typename TKey, typename TGroup>
void Rx::CKeyValueMap< TKey, TGroup >::SetParamSetCallback ( TParamSetCallback  pxCallback,
void *  pvContext 
)
inline

Set the parameter set callback function.

Parameters
pxCallbackThe callback.
pvContext[in] A context pointer.
template<typename TKey, typename TGroup>
size_t Rx::CKeyValueMap< TKey, TGroup >::Size ( ) const
inline

Gets the size of this map.

Returns
The number if values in this map.
template<typename TKey, typename TGroup>
CRxString Rx::CKeyValueMap< TKey, TGroup >::ToString ( EValueType::ID  eValueType) const
inline

Gets the string representation of the given value type.

Parameters
eValueTypeThe value type.
Returns
The value type as a string.

Member Data Documentation

template<typename TKey, typename TGroup>
void* Rx::CKeyValueMap< TKey, TGroup >::m_pvCallbackContext
template<typename TKey, typename TGroup>
TParamSetCallback Rx::CKeyValueMap< TKey, TGroup >::m_pxCallback
template<typename TKey, typename TGroup>
std::map< TKey, SValue < CRxArrayDouble > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapArrayDouble
template<typename TKey, typename TGroup>
std::map< TKey, SValue < CRxArrayString > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapArrayString
template<typename TKey, typename TGroup>
std::map< TKey, SValue < CRxArrayUInt > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapArrayUInt
template<typename TKey, typename TGroup>
TMapDefs Rx::CKeyValueMap< TKey, TGroup >::m_xMapDefs
template<typename TKey, typename TGroup>
std::map< TKey, SValue < double > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapDouble
template<typename TKey, typename TGroup>
std::map< TKey, SValue < CRxString > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapString
template<typename TKey, typename TGroup>
std::map< TKey, SValue < unsigned > > Rx::CKeyValueMap< TKey, TGroup >::m_xMapUInt