/usr/include/cegui-0.8.7/CEGUI/FunctorCopySlot.h is in libcegui-mk2-dev 0.8.7-2.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | /************************************************************************
created: Tue Feb 28 2006
authors: Paul D Turner <paul@cegui.org.uk>
Martin Preisler <martin@preisler.me>
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2014 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIFunctorCopySlot_h_
#define _CEGUIFunctorCopySlot_h_
#include "CEGUI/SlotFunctorBase.h"
// Start of CEGUI namespace section
namespace CEGUI
{
namespace FunctorCopySlot_detail
{
typedef char Yes;
typedef int No;
template<typename T>
struct HasBoolEventArgsConstOp
{
template<typename U, bool (U::*)(const EventArgs&) const> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasBoolEventArgsOp
{
template<typename U, bool (U::*)(const EventArgs&)> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasVoidEventArgsConstOp
{
template<typename U, void (U::*)(const EventArgs&) const> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasVoidEventArgsOp
{
template<typename U, void (U::*)(const EventArgs&)> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasBoolNoArgsConstOp
{
template<typename U, bool (U::*)() const> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasBoolNoArgsOp
{
template<typename U, bool (U::*)()> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
template<typename T>
struct HasVoidNoArgsConstOp
{
template<typename U, void (U::*)() const> struct SFINAE {};
template<typename U> static Yes Test(SFINAE<U, &U::operator()>*);
template<typename U> static No Test(...);
static const bool Value = sizeof(Test<T>(0)) == sizeof(Yes);
};
// The following 3 templates use the same idea as boost::disable_if
template <bool B, class T = void>
struct DisableIfC
{
typedef T Type;
};
template <class T>
struct DisableIfC<true, T>
{};
template <class Cond, class T = void>
struct DisableIf : public DisableIfC<Cond::Value, T>
{};
// The following is just overload trickery to accommodate 8 allowed
// operator() signatures:
//
// 1) bool (const EventArgs&) const = BoolEventArgsConstOp
// 2) bool (const EventArgs&) = BoolEventArgsOp
// 3) void (const EventArgs&) const = VoidEventArgsConstOp
// 4) void (const EventArgs&) = VoidEventArgsOp
// 5) bool () const = BoolNoArgsConstOp
// 6) bool () = BoolNoArgsOp
// 7) void () const = VoidNoArgsConstOp
// 8) void () = VoidNoArgsOp
//
// The calls are priorised as outlined above, if call 1) is possible, no
// other variants are tried, ...
template<typename T>
inline bool call(const T& functor, bool(T::*member_fn)(const EventArgs&) const, const EventArgs& args,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0
)
{
return CEGUI_CALL_MEMBER_FN(functor, member_fn)(args);
}
template<typename T>
inline bool call(T& functor, bool(T::*member_fn)(const EventArgs&), const EventArgs& args,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0
)
{
return CEGUI_CALL_MEMBER_FN(functor, member_fn)(args);
}
template<typename T>
inline bool call(const T& functor, void(T::*member_fn)(const EventArgs&) const, const EventArgs& args,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0
)
{
CEGUI_CALL_MEMBER_FN(functor, member_fn)(args);
return true;
}
template<typename T>
inline bool call(T& functor, void(T::*member_fn)(const EventArgs&), const EventArgs& args,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsConstOp<T> >::Type* = 0,
void* = 0,
void* = 0,
void* = 0,
void* = 0
)
{
CEGUI_CALL_MEMBER_FN(functor, member_fn)(args);
return true;
}
template<typename T>
inline bool call(const T& functor, bool(T::*member_fn)() const, const EventArgs& /*args*/,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsOp<T> >::Type* = 0,
void* = 0,
void* = 0,
void* = 0
)
{
return CEGUI_CALL_MEMBER_FN(functor, member_fn)();
}
template<typename T>
inline bool call(T& functor, bool(T::*member_fn)(), const EventArgs& /*args*/,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasBoolNoArgsConstOp<T> >::Type* = 0,
void* = 0,
void* = 0
)
{
return CEGUI_CALL_MEMBER_FN(functor, member_fn)();
}
template<typename T>
inline bool call(const T& functor, void(T::*member_fn)() const, const EventArgs& /*args*/,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasBoolNoArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolNoArgsOp<T> >::Type* = 0,
void* = 0
)
{
CEGUI_CALL_MEMBER_FN(functor, member_fn)();
return true;
}
template<typename T>
inline bool call(T& functor, void(T::*member_fn)(), const EventArgs& /*args*/,
typename DisableIf<HasBoolEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasVoidEventArgsOp<T> >::Type* = 0,
typename DisableIf<HasBoolNoArgsConstOp<T> >::Type* = 0,
typename DisableIf<HasBoolNoArgsOp<T> >::Type* = 0,
typename DisableIf<HasVoidNoArgsConstOp<T> >::Type* = 0
)
{
CEGUI_CALL_MEMBER_FN(functor, member_fn)();
return true;
}
}
/*!
\brief
Slot template class that creates a functor that calls back via a copy of a
functor object.
*/
template<typename T>
class FunctorCopySlot : public SlotFunctorBase
{
public:
FunctorCopySlot(const T& functor):
d_functor(functor)
{}
virtual bool operator()(const EventArgs& args)
{
return FunctorCopySlot_detail::call<T>(d_functor, &T::operator(), args);
}
private:
T d_functor;
};
}
#endif // end of guard _CEGUIFunctorCopySlot_h_
|