All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Runtime Typing

Classes having to do with run-time typing. More...

+ Collaboration diagram for Runtime Typing:

Files

file  enum.h
 
file  safeTypeCompare.h
 Safely compare C++ RTTI type structures.
 
file  traits.h
 
file  typeInfoMap.h
 

Classes

class  TfEnum
 An enum class that records both enum type and enum value. More...
 
class  TfTraits
 Type-querying abilities. More...
 
class  TfTypeInfoMap< VALUE >
 A map whose key is a const std::type_info&, or a string alias. More...
 

Macros

#define TF_ADD_ENUM_NAME(VAL,...)
 Macro used to associate a name with an enumerated value. More...
 

Detailed Description

Classes having to do with run-time typing.


Class Documentation

class TfTraits

Type-querying abilities.

TfTraits is a class used for compile-time type queries. Types retrieved from TfTraits are compile-time types, while values are compile-time values (i.e. constants).

Types

The following types are defined by TfTraits:

* TfTraits::Type<T>::UnderlyingType
*

The above removes a single level of pointer-ness or a reference from T, as well as any constness and returns the result. For example, both int and int* are mapped to int, but int** is mapped to int*.

* TfTraits::Type<T>::NoRefType;
*

The above transforms a reference-type into a non-reference type. For example, both int& and int are mapped to int, but int* is mapped to int*.

* TfTraits::Type<T>::PointerType;
*

The above transforms any type T to T*, except that a type T& is transformed to T*.

* TfTraits::Type<T>::RefType
*

The above transforms a non-reference-type into a reference type. For example, both int& and int are mapped to int&. However, RefType is not defined if T is an array (either dimensioned or undimensioned).

* TfTraits::Type<T>::AvoidCopyingType
*

The above maps all types T back to themselves, except for a type that is neither a pointer nor reference; in this case, the type is mapped to a reference to a const reference to itself (i.e. an & ) is added to the type.

* TfTraits::Type<T>::PtrOrRefType
*

The above maps all types T back to themselves, except for a type that is neither a pointer nor reference; in this case, the type is mapped to a reference to a reference to itself (i.e. an & ) is added to the type. This differs from AvoidCopyingType in that it does not produce a const reference.

Values

Any values retrieved using TfTraits are actually compile-time constants; as a result, an if/else test with such a value usually results in only one branch of the conditional actually generating code (although both branches must be legal C++).

The following boolean values are defined:

* TfTraits::Type<T>::isPointer
* TfTraits::Type<T>::isReference
* TfTraits::Type<T>::isConst
* TfTraits::TypeCompare<A,B>::isEqual
*

The isPointer value is true for any type T that is either a pointer or an array; the isReference is true if T is a reference, and isConst is true if T is constant qualified.

Examples

* template <class T>
* void PassThru(T arg1) {
* // this always avoids any significant copying:
* // cache1 is either a pointer or a reference
* TfTraits::Type<T>::AvoidCopyingType cache1 = arg1;
*
* typedef TfTraits::Type<T>::UnderlyingType UT;
*
* if (TfTraits::Type<UT>::isPointer) {
* cout << "hey, this is a pointer to a pointer!\n";
* }
* if (TfTraits::Type<T>::isConst) {
* cout << "original arg was constant\n";
* }
* }
*

Definition at line 144 of file traits.h.

Macro Definition Documentation

#define TF_ADD_ENUM_NAME (   VAL,
  ... 
)

Macro used to associate a name with an enumerated value.

TF_ADD_ENUM_NAME() registers a name for an enumerated value so that the association can be accessed in calls to TfEnum::GetValueFromName(), TfEnum::GetValueFromFullName(), TfEnum::GetName(), and TfEnum::GetFullName(). It's first argument, VAL, is the symbolic name of the enumerated value or a TfEnum instance constructed from it. The name defined for the value is created by putting double quotes around the VAL argument.

An optional second argument, DISPLAY, is a name to be used for display purposes (i.e. in a user interface). The display name can contain characters like spaces and punctuation, and does not need to be a unique string. If this argument is not specified, the display name will be derived from VAL.

Only the names for which TF_ADD_ENUM_NAME() is called will be accessible with the name/value methods; you can hide values from this mechanism by not adding them.

Please note that the best way to call TF_ADD_ENUM_NAME() is using the TfRegistryManager macro TF_REGISTRY_FUNCTION().

Definition at line 439 of file enum.h.