Loading...
Searching...
No Matches
TfTypeInfoMap< VALUE > Class Template Reference

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

#include <typeInfoMap.h>

Public Member Functions

bool Exists (const std::type_info &key) const
 Return true if the given key is present in the map.
 
bool Exists (const std::string &key) const
 Return true if the given key is present in the map.
 
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.
 
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.
 
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.
 
void Set (const std::type_info &key, const VALUE &value)
 Set the value for a given key.
 
void Set (const std::string &key, const VALUE &value)
 Set the value for a given key.
 
bool CreateAlias (const std::string &alias, const std::string &key)
 Create an alias for a key.
 
bool CreateAlias (const std::string &alias, const std::type_info &key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void Remove (const std::type_info &key)
 Remove this key (and any aliases associated with it).
 
void Remove (const std::string &key)
 Remove this key (and any aliases associated with it).
 

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

◆ TfTypeInfoMap()

TfTypeInfoMap ( )
inline

Definition at line 69 of file typeInfoMap.h.

Member Function Documentation

◆ CreateAlias() [1/2]

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

◆ CreateAlias() [2/2]

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

◆ Exists() [1/2]

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

◆ Exists() [2/2]

bool 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.

◆ Find() [1/3]

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.

◆ Find() [2/3]

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.

◆ Find() [3/3]

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.

◆ Remove() [1/2]

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

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

Definition at line 187 of file typeInfoMap.h.

◆ Remove() [2/2]

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

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

Definition at line 182 of file typeInfoMap.h.

◆ Set() [1/2]

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

◆ Set() [2/2]

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


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