HDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfTypeInfoMap< VALUE > Class Template Reference

#include <typeInfoMap.h>

Public Member Functions

 TfTypeInfoMap ()
 
bool Exists (const std::type_info &key) const
 Return true if the given key is present in the map. More...
 
bool Exists (const std::string &key) const
 
VALUE * Find (const std::type_info &key) const
 
template<class Upgrader >
VALUE * Find (const std::type_info &key, Upgrader &upgrader)
 
VALUE * Find (const std::string &key) const
 
void Set (const std::type_info &key, const VALUE &value)
 
void Set (const std::string &key, const VALUE &value)
 
bool CreateAlias (const std::string &alias, const std::string &key)
 
bool CreateAlias (const std::string &alias, const std::type_info &key)
 
void Remove (const std::type_info &key)
 Remove this key (and any aliases associated with it). More...
 
void Remove (const std::string &key)
 Remove this key (and any aliases associated with it). More...
 

Detailed Description

template<class VALUE>
class TfTypeInfoMap< VALUE >

A map whose key is a const std::type_info&, or a string alias.

A TfTypeInfoMap stores values of arbitrary type (template parameter VALUE) under a key that is either a const std::type_info&, or an std::string. Note that the std::type_info structure is many-to-one with respect to its name, i.e. two distinct instances of a std::type_info can represent the same type. Thus, a naive implementation that does pointer comparison on the address of a std::type_info can fail. The TfTypeInfoMap takes care of this aliasing.

Additionally, the table lets one create additional string aliases for a given entry.

Definition at line 62 of file typeInfoMap.h.

Constructor & Destructor Documentation

template<class VALUE >
TfTypeInfoMap< VALUE >::TfTypeInfoMap ( )
inline

Definition at line 69 of file typeInfoMap.h.

Member Function Documentation

template<class VALUE >
bool TfTypeInfoMap< VALUE >::CreateAlias ( const std::string alias,
const std::string key 
)
inline

Create an alias for a key.

Queries with a key of alias will return the same data associated with queries for key.

If key is not presently a member of the map, this function does nothing and returns false.

Definition at line 164 of file typeInfoMap.h.

template<class VALUE >
bool TfTypeInfoMap< VALUE >::CreateAlias ( const std::string alias,
const std::type_info &  key 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 173 of file typeInfoMap.h.

template<class VALUE >
bool TfTypeInfoMap< VALUE >::Exists ( const std::type_info &  key) const
inline

Return true if the given key is present in the map.

Definition at line 72 of file typeInfoMap.h.

template<class VALUE >
bool TfTypeInfoMap< VALUE >::Exists ( const std::string key) const
inline

Return true if the given key is present in the map.

Note that lookup by std::type_info is preferable for speed reasons.

Definition at line 79 of file typeInfoMap.h.

template<class VALUE >
VALUE* TfTypeInfoMap< VALUE >::Find ( const std::type_info &  key) const
inline

Return a pointer to the value stored under key, and NULL if key is not a key in the map.

Definition at line 85 of file typeInfoMap.h.

template<class VALUE >
template<class Upgrader >
VALUE* TfTypeInfoMap< VALUE >::Find ( const std::type_info &  key,
Upgrader &  upgrader 
)
inline

Return a pointer to the value stored under key, and NULL if key is not a key in the map. For efficiency of future lookups this will cache the result if it falls back to a string based lookup. In that case before updating the cache it will call the functor upgrader to allow the client to upgrade any lock to exclusive access.

Definition at line 101 of file typeInfoMap.h.

template<class VALUE >
VALUE* TfTypeInfoMap< VALUE >::Find ( const std::string key) const
inline

Return a pointer to the value stored under key, and NULL if key is not a key in the map.

Note that lookup by std::type_info is preferable for speed reasons.

Definition at line 117 of file typeInfoMap.h.

template<class VALUE >
void TfTypeInfoMap< VALUE >::Remove ( const std::type_info &  key)
inline

Remove this key (and any aliases associated with it).

Definition at line 182 of file typeInfoMap.h.

template<class VALUE >
void TfTypeInfoMap< VALUE >::Remove ( const std::string key)
inline

Remove this key (and any aliases associated with it).

Definition at line 187 of file typeInfoMap.h.

template<class VALUE >
void TfTypeInfoMap< VALUE >::Set ( const std::type_info &  key,
const VALUE &  value 
)
inline

Set the value for a given key.

Note that if key is not already in the table, this creates a new entry. Also, key.name() is automatically made linked with this entry, so that future queries can be made via key.name(), though lookup by std::type_info is greatly preferred.

Definition at line 128 of file typeInfoMap.h.

template<class VALUE >
void TfTypeInfoMap< VALUE >::Set ( const std::string key,
const VALUE &  value 
)
inline

Set the value for a given key.

Note that if key is not already in the table, this creates a new entry. Also, lookup by std::type_info is preferable for speed reasons.

Definition at line 142 of file typeInfoMap.h.


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