CCallbackWrapper.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_ring_CCallback_Wrapper_h_
#define polybori_ring_CCallback_Wrapper_h_
// include basic definitions
#include <polybori/pbori_defs.h>
#include "CMemberFunctionTraits.h"
BEGIN_NAMESPACE_PBORI
template <class Type, class ResultType, class ArgType>
class CCallbackFacade {
public:
ResultType operator()(ArgType arg) const {
return (static_cast<const Type&>(*this).object .*
static_cast<const Type&>(*this).function)(arg);
}
};
template <class Type, class ArgType>
class CCallbackFacade<Type, void, ArgType> {
public:
void operator()(ArgType arg) const {
(static_cast<const Type&>(*this).object .*
static_cast<const Type&>(*this).function)(arg);
}
};
template <class MemberFuncPtr>
class CCallbackWrapper:
public CCallbackFacade< CCallbackWrapper<MemberFuncPtr>,
typename CMemberFunctionTraits<MemberFuncPtr>::result_type,
typename CMemberFunctionTraits<MemberFuncPtr>::argument_type> {
typedef CCallbackWrapper self;
public:
typedef CMemberFunctionTraits<MemberFuncPtr> traits;
friend class CCallbackFacade<self, typename traits::result_type,
typename traits::argument_type>;
typedef typename traits::object_reference reference;
CCallbackWrapper(reference value, MemberFuncPtr ptr):
object(value), function(ptr) { }
private:
reference object;
MemberFuncPtr function;
};
END_NAMESPACE_PBORI
#endif
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
CMemberFunctionTraits.h
polybori::CCallbackWrapper::reference
traits::object_reference reference
Reference to object.
Definition: CCallbackWrapper.h:87
polybori::CCallbackWrapper
This template class defines a functional, which wraps operator .*, which is the callback of a dynamic...
Definition: CCallbackWrapper.h:72
polybori::CCallbackFacade< Type, void, ArgType >::operator()
void operator()(ArgType arg) const
Apply member function pointer to argument (avoid returning void())
Definition: CCallbackWrapper.h:57
polybori::object
Definition: embed.h:188
pbori_defs.h
polybori::CCallbackFacade
Variant for constant non-void member functions.
Definition: CCallbackWrapper.h:41
polybori::CMemberFunctionTraits
This template class defines related types for member function pointer.
Definition: CMemberFunctionTraits.h:33
polybori::CCallbackWrapper::traits
CMemberFunctionTraits< MemberFuncPtr > traits
Related types.
Definition: CCallbackWrapper.h:81
polybori::CCallbackFacade::operator()
ResultType operator()(ArgType arg) const
Apply member function pointer to argument.
Definition: CCallbackWrapper.h:45