16#ifndef A_UTIL_UTIL_DELEGATE_DECL_HEADER_INCLUDED
17#define A_UTIL_UTIL_DELEGATE_DECL_HEADER_INCLUDED
28template <
typename ReturnType>
29class DelegateInterface {
31 virtual ~DelegateInterface();
32 virtual ReturnType invoke() = 0;
33 virtual DelegateInterface<ReturnType>* clone() = 0;
36template <
typename ReturnType>
37class FunctionDelegate :
public DelegateInterface<ReturnType> {
38 typedef ReturnType (*Function)();
41 FunctionDelegate(Function f);
42 virtual ReturnType invoke();
43 virtual DelegateInterface<ReturnType>* clone();
49template <
typename ReturnType,
typename Method,
typename Instance>
50class MethodDelegate :
public DelegateInterface<ReturnType> {
52 MethodDelegate(Method method, Instance& instance);
53 virtual ReturnType invoke();
54 virtual DelegateInterface<ReturnType>* clone();
64template <
typename ReturnType,
typename ParamType>
65class DelegateInterface {
67 virtual ~DelegateInterface();
68 virtual ReturnType invoke(ParamType) = 0;
69 virtual DelegateInterface<ReturnType, ParamType>* clone() = 0;
72template <
typename ReturnType,
typename ParamType>
73class FunctionDelegate :
public DelegateInterface<ReturnType, ParamType> {
74 typedef ReturnType (*Function)(ParamType);
77 FunctionDelegate(Function f);
78 virtual ReturnType invoke(ParamType param);
79 virtual DelegateInterface<ReturnType, ParamType>* clone();
85template <
typename ReturnType,
typename ParamType,
typename Method,
typename Instance>
86class MethodDelegate :
public DelegateInterface<ReturnType, ParamType> {
88 MethodDelegate(Method method, Instance& inst);
89 virtual ReturnType invoke(ParamType param);
90 virtual DelegateInterface<ReturnType, ParamType>* clone();
100template <
typename DelegateType>
105 DelegateBase(
const DelegateBase& other);
106 DelegateBase& operator=(
const DelegateBase& other);
108 void setDelegate(DelegateType* delegate);
109 DelegateType* getDelegate();
110 const DelegateType* getDelegate()
const;
113 operator bool()
const;
116 DelegateType* _ptr_to_callee;
127template <
typename ReturnType>
129 :
public detail::DelegateBase<detail::delegates::DelegateInterface<ReturnType>> {
143 template <
typename Method,
typename Instance>
153 typedef detail::DelegateBase<detail::delegates::DelegateInterface<ReturnType>> Base;
161template <
typename ReturnType,
typename ParamType>
163 :
public detail::DelegateBase<detail::functions::DelegateInterface<ReturnType, ParamType>> {
178 template <
typename Method,
typename Instance>
189 typedef detail::DelegateBase<detail::functions::DelegateInterface<ReturnType, ParamType>> Base;
ReturnType operator()()
Definition delegate_impl.h:194
NullaryDelegate(ReturnType(*Function)())
Definition delegate_impl.h:175
UnaryDelegate(Method method, Instance &instance)
Definition delegate_impl.h:212
ReturnType operator()(ParamType param)
Definition delegate_impl.h:222
UnaryDelegate(ReturnType(*Function)(ParamType))
Definition delegate_impl.h:202
Serves as component for features which are considered experimental.
Definition base.h:26
Serves as the root component, with common functionality documented in core functionality.
Definition base.h:24