RTTI Different methods for
runtime type identification.
More...
|
Functions
|
|
template<typename T, typename U> |
| const std::vector< T * > |
castSubClassVectorToParentClassVector
(const std::vector< U * > sub_class_vector) |
| |
The function casts a vector with
links of objects of class U, which is the sub class of the
class T, to links of objects of class T.
|
|
template<typename T> |
| void * |
getNew () |
| |
Return a void pointer to a new
instance of the class.
|
|
template<typename T, typename U> |
| bool |
isKindOf (const U
&u) |
| |
Return true if u is a
kind of T.
|
|
template<typename T, typename U> |
| bool |
isPointerKindOf
(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.
|
Detailed Description
RTTI Different methods for
runtime type identification.
Function Documentation
| template<typename
T, typename U> |
| T*
BNPP::RTTI::castTo |
( |
const U *
|
u |
) |
|
|
| |
Cast an object to a specialized class.
Example:
-
Composite* composite = ...;
...
if (RTTI::isKindOf<Atom>(composite))
{
Atom* atom = RTTI::castTo<Atom>(*composite);
...
atom->setCharge(0);
...
}
|
| template<typename
T> |
| void*
BNPP::RTTI::getNew |
( |
|
) |
|
|
| |
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 Serializer needs a
function for the dynamic creation of objects.
|
| template<typename
T, typename U> |
| bool
BNPP::RTTI::isInstanceOf |
( |
const U
& |
u |
) |
|
|
| |
Return { true} if a given object is an instance of a
given class.
If { u} is an instance of { T}, this predicate returns
{ true}. If { u} is an instance of a class that is
derived from { T} or a base class of { T}, it returns
false.
|
| template<typename
T, typename U> |
| bool
BNPP::RTTI::isKindOf |
( |
const U
& |
u |
) |
|
|
| |
Return true if u is a kind of T.
If u is an instance of a class derived
from T, this predicate returns true:
-
Protein p;
bool is_participant = RTTI::isKindOf<Participant>(p);
|
| template<typename
T, typename U> |
| bool
BNPP::RTTI::isPointerKindOf |
( |
const U *
|
u |
) |
|
|
| |
Return true if u is a kind of T.
If u is an instance of a class derived
from T, this predicate returns true:
-
Protein* p = new Protein();
bool is_participant = RTTI::isPointerKindOf<Participant>(p);
|