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

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

Inherits noncopyable.

Public Member Functions

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
 Return true if the given key is present in the map. More...
 
VALUE * Find (const std::type_info &key) const
 Return a pointer to the value stored under key, and NULL if key is not a key in the map. More...
 
template<class Upgrader >
VALUE * Find (const std::type_info &key, Upgrader &upgrader)
 Return a pointer to the value stored under key, and NULL if key is not a key in the map. More...
 
VALUE * Find (const std::string &key) const
 Return a pointer to the value stored under key, and NULL if key is not a key in the map. More...
 
void Set (const std::type_info &key, const VALUE &value)
 Set the value for a given key. More...
 
void Set (const std::string &key, const VALUE &value)
 Set the value for a given key. More...
 
bool CreateAlias (const std::string &alias, const std::string &key)
 Create an alias for a key. More...
 
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 63 of file typeInfoMap.h.

Member Function Documentation

bool 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 163 of file typeInfoMap.h.

bool 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 172 of file typeInfoMap.h.

bool Exists ( const std::type_info &  key) const
inline

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

Definition at line 71 of file typeInfoMap.h.

bool 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 78 of file typeInfoMap.h.

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 84 of file typeInfoMap.h.

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 100 of file typeInfoMap.h.

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 116 of file typeInfoMap.h.

void Remove ( const std::type_info &  key)
inline

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

Definition at line 181 of file typeInfoMap.h.

void Remove ( const std::string &  key)
inline

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

Definition at line 186 of file typeInfoMap.h.

void 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 127 of file typeInfoMap.h.

void 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 141 of file typeInfoMap.h.


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