/usr/include/polybori/ring/CCallbackWrapper.h is in libbrial-dev 0.8.5-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | // -*- c++ -*-
//*****************************************************************************
/** @file CCallbackWrapper.h
*
* @author Alexander Dreyer
* @date 2010-08-30
*
* This file define a functional, which wraps the callback operator .*, by
* managing member function pointers and the corresponding object.
*
* @par Copyright:
* (c) 2010 by The PolyBoRi Team
*
**/
//*****************************************************************************
#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
/** @class CCallbackFacade
* @brief This template class defines a facade for applying operator @c .* in
* @c operator() .
*
* If applies a stored member function pointer (together with a stored object
* reference) to the argument of operator().
*
* It is to be used as a face of @c Type, e. g. for @c CCallbackWrapper below.
*
* @note Specialized variant to void member functions
* @attention Currently, the class supports unary functions only.
**/
/// Variant for constant non-void member functions
template <class Type, class ResultType, class ArgType>
class CCallbackFacade {
public:
/// Apply member function pointer to argument
ResultType operator()(ArgType arg) const {
return (static_cast<const Type&>(*this).object .*
static_cast<const Type&>(*this).function)(arg);
}
};
/// Specialized variant for constant void member functions
template <class Type, class ArgType>
class CCallbackFacade<Type, void, ArgType> {
public:
/// Apply member function pointer to argument (avoid returning @c void())
void operator()(ArgType arg) const {
(static_cast<const Type&>(*this).object .*
static_cast<const Type&>(*this).function)(arg);
}
};
/** @class CCallbackWrapper
* @brief This template class defines a functional, which wraps operator .*,
* which is the callback of a dynamic member function wrt. a given object.
*
* A reference of a given object is stored as well as the function pointer. @c
* operator() does the actual application.
*
**/
template <class MemberFuncPtr>
class CCallbackWrapper:
public CCallbackFacade< CCallbackWrapper<MemberFuncPtr>,
typename CMemberFunctionTraits<MemberFuncPtr>::result_type,
typename CMemberFunctionTraits<MemberFuncPtr>::argument_type> {
/// Type of *this
typedef CCallbackWrapper self;
public:
/// Related types
typedef CMemberFunctionTraits<MemberFuncPtr> traits;
/// Facade which defines @c operator() needs to access private members
friend class CCallbackFacade<self, typename traits::result_type,
typename traits::argument_type>;
/// Reference to object
typedef typename traits::object_reference reference;
/// Constructor
CCallbackWrapper(reference value, MemberFuncPtr ptr):
object(value), function(ptr) { }
private:
reference object;
MemberFuncPtr function;
};
END_NAMESPACE_PBORI
#endif
|