ug4
ug::bridge::ClassCastProvider Class Reference

provides castings from derived classes to base classes More...

#include <class_name_provider.h>

Static Public Member Functions

template<typename TBase , typename TDerived >
static void add_cast_func ()
 add a cast function to the registry: Casts: Derived -> Base More...
 
static void * cast_to_base_class (void *pDerivVoid, const ClassNameNode *&node, const std::string &baseName)
 cast a pointer to the desired base class More...
 
static const void * cast_to_base_class (const void *pDerivVoid, const ClassNameNode *&node, const std::string &baseName)
 cast a pointer to the desired base class More...
 
template<typename T >
static T * cast_to (void *pDerivVoid, const ClassNameNode *&node)
 casts a void pointer to a concrete class More...
 
template<typename T >
static const T * cast_to (const void *pDerivVoid, const ClassNameNode *&node)
 cast a pointer to the desired base class More...
 
template<typename T >
static SmartPtr< T > cast_to (SmartPtr< void > pDerivVoid, const ClassNameNode *&node)
 cast a pointer to the desired base class More...
 
template<typename T >
static ConstSmartPtr< T > cast_to (ConstSmartPtr< void > pDerivVoid, const ClassNameNode *&node)
 cast a pointer to the desired base class More...
 

Protected Types

typedef void *(* CastFunc) (void *)
 

Static Protected Attributes

static std::map< std::pair< const ClassNameNode *, const ClassNameNode * >, CastFuncm_mmCast = std::map<std::pair<const ClassNameNode*, const ClassNameNode*>, void* (*)(void*)> ()
 

Detailed Description

provides castings from derived classes to base classes

Member Typedef Documentation

◆ CastFunc

typedef void*(* ug::bridge::ClassCastProvider::CastFunc) (void *)
protected

Member Function Documentation

◆ add_cast_func()

template<typename TBase , typename TDerived >
static void ug::bridge::ClassCastProvider::add_cast_func ( )
static

add a cast function to the registry: Casts: Derived -> Base

◆ cast_to() [1/4]

template<typename T >
static const T* ug::bridge::ClassCastProvider::cast_to ( const void *  pDerivVoid,
const ClassNameNode *&  node 
)
static

cast a pointer to the desired base class

This method casts a void pointer to a given derived class to the void pointer of a base class. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
[in]baseNamename of base class the pointer should be casted to
Returns
void* to base class

◆ cast_to() [2/4]

template<typename T >
static ConstSmartPtr<T> ug::bridge::ClassCastProvider::cast_to ( ConstSmartPtr< void >  pDerivVoid,
const ClassNameNode *&  node 
)
static

cast a pointer to the desired base class

This method casts a void pointer to a given derived class to the void pointer of a base class. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
[in]baseNamename of base class the pointer should be casted to
Returns
void* to base class

◆ cast_to() [3/4]

template<typename T >
static SmartPtr<T> ug::bridge::ClassCastProvider::cast_to ( SmartPtr< void >  pDerivVoid,
const ClassNameNode *&  node 
)
static

cast a pointer to the desired base class

This method casts a void pointer to a given derived class to the void pointer of a base class. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
[in]baseNamename of base class the pointer should be casted to
Returns
void* to base class

◆ cast_to() [4/4]

template<typename T >
static T* ug::bridge::ClassCastProvider::cast_to ( void *  pDerivVoid,
const ClassNameNode *&  node 
)
static

casts a void pointer to a concrete class

This method casts a void pointer to a given derived classed and returns it as a reinterpreted cast to the type specified by the template argument. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
Returns
void* to base class

◆ cast_to_base_class() [1/2]

const void * ug::bridge::ClassCastProvider::cast_to_base_class ( const void *  pDerivVoid,
const ClassNameNode *&  node,
const std::string &  baseName 
)
static

cast a pointer to the desired base class

This method casts a void pointer to a given derived class to the void pointer of a base class. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
[in]baseNamename of base class the pointer should be casted to
Returns
void* to base class

References ug::baseName(), and cast_to_base_class().

◆ cast_to_base_class() [2/2]

void * ug::bridge::ClassCastProvider::cast_to_base_class ( void *  pDerivVoid,
const ClassNameNode *&  node,
const std::string &  baseName 
)
static

cast a pointer to the desired base class

This method casts a void pointer to a given derived class to the void pointer of a base class. If conversion fails, an exception of type UGError_ClassCastFailed is thrown.

Parameters
[in]pDerivVoidvoid pointer to Derived object
[in,out]nodeon entry: class name node corresponding to pDerivVoid on exit: class name node corresponding to baseName
[in]baseNamename of base class the pointer should be casted to
Returns
void* to base class

References ug::bridge::ClassNameNode::base_class(), ug::baseName(), ug::bridge::ClassNameTreeWay(), m_mmCast, ug::bridge::ClassNameNode::name(), and UG_ERR_LOG.

Referenced by cast_to_base_class(), and Java_edu_gcsc_vrl_ug_UG__1invokeMethod().

Member Data Documentation

◆ m_mmCast

std::map< std::pair< const ClassNameNode *, const ClassNameNode * >, void *(*)(void *)> ug::bridge::ClassCastProvider::m_mmCast = std::map<std::pair<const ClassNameNode*, const ClassNameNode*>, void* (*)(void*)> ()
staticprotected

Referenced by cast_to_base_class().


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