Functions | |
template<typename T> | |
const T & | getDefault () |
Return a reference to a static default instance of the corresponding class. | |
template<typename T> | |
void * | getNew () |
Return a void pointer to a new instance of the class. | |
template<typename T> | |
const char * | getName () |
Return the name of the class. | |
template<typename T> | |
void * | getClassID () |
Return a void pointer that is unique for each class. | |
template<typename T> | |
const char * | getStreamName () |
Return the demangled class name. | |
template<typename T, typename U> | |
bool | isKindOf (const U &u) |
Return true if u is a kind of T. | |
template<typename T, typename U> | |
T * | castTo (const U &u) |
Cast an object to a specialized class. | |
template<typename T, typename U> | |
bool | isInstanceOf (const U &u) |
Return true if a given object is an instance of a given class. |
ANSI C++ provides support for runtime type identification (RTTI). However, the support is very basic. The template functions of the RTTI namespace provide a more readable support for RTTI. It defines predicates such as isKindOf that simplify tests on the hereditary relationship of different objects.
Molecule& m =...; ... if (RTTI::isKindOf<Protein>(m)) { // perform some protein specific operations } else { // this is only a molecule... }
|
Cast an object to a specialized class. Example:
|
|
Return a void pointer that is unique for each class.
|
|
Return a reference to a static default instance of the corresponding class. This method is basically intended to provide a default object for certain operations that require an instance of a certain class without really using this instance. It is mainly used inside the RTTI class. |
|
Return the name of the class.
This method returns the name of the class as given by |
|
Return a void pointer to a new instance of the class. Use this method to provide an easy factory for objects of a certain class. The main use of this function lies in object persistence. The PersistenceManager needs a function for the dynamic creation of objects. |
|
Return the demangled class name. The class name is demangled (as far as possible) and in the resulting string blanks are substituted by underscores, so the name can be read from a stream as one string. The typical usage is something like String class_name = RTTI::getStreamName<Residue>(); ... |
|
Return true if a given object is an instance of a given class.
If |
|
Return true if
If
|