Library of Assembled Shared Sources
dispatcher_r_15.h
Go to the documentation of this file.
1/*
2 * *** ATTENTION! DO NOT MODIFY THIS FILE DIRECTLY! ***
3 *
4 * It has automatically been generated from dispatcher_r_x.tmpl.h
5 * by param_expander.py on Tue Oct 7 01:22:02 2025.
6 */
7
8/** @file
9 * @author Bram de Greve (bram@cocamware.com)
10 * @author Tom De Muer (tom@cocamware.com)
11 *
12 * *** BEGIN LICENSE INFORMATION ***
13 *
14 * The contents of this file are subject to the Common Public Attribution License
15 * Version 1.0 (the "License"); you may not use this file except in compliance with
16 * the License. You may obtain a copy of the License at
17 * http://lass.sourceforge.net/cpal-license. The License is based on the
18 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
19 * use of software over a computer network and provide for limited attribution for
20 * the Original Developer. In addition, Exhibit A has been modified to be consistent
21 * with Exhibit B.
22 *
23 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
24 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
25 * language governing rights and limitations under the License.
26 *
27 * The Original Code is LASS - Library of Assembled Shared Sources.
28 *
29 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
30 * The Original Developer is the Initial Developer.
31 *
32 * All portions of the code written by the Initial Developer are:
33 * Copyright (C) 2004-2025 the Initial Developer.
34 * All Rights Reserved.
35 *
36 * Contributor(s):
37 *
38 * Alternatively, the contents of this file may be used under the terms of the
39 * GNU General Public License Version 2 or later (the GPL), in which case the
40 * provisions of GPL are applicable instead of those above. If you wish to allow use
41 * of your version of this file only under the terms of the GPL and not to allow
42 * others to use your version of this file under the CPAL, indicate your decision by
43 * deleting the provisions above and replace them with the notice and other
44 * provisions required by the GPL License. If you do not delete the provisions above,
45 * a recipient may use your version of this file under either the CPAL or the GPL.
46 *
47 * *** END LICENSE INFORMATION ***
48 */
49
50#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_IMPL_DISPATCHER_R_15_H
51#define LASS_GUARDIAN_OF_INCLUSION_UTIL_IMPL_DISPATCHER_R_15_H
52
54#include "../callback_common.h"
55
56// --- NEW INTERFACES ----------------------------------------------------------
57
58namespace lass
59{
60namespace util
61{
62namespace impl
63{
64
65/** abstract base class of all dispatchers for lass::util::CallbackR15.
66 * @internal
67 * @sa CallbackR15
68 * @author Bram de Greve [Bramz]
69 */
70template
71<
72 typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15
73>
74class DispatcherR15: public TDispatcherAllocatorBase
75{
76public:
77
78 DispatcherR15() {}
79 virtual ~DispatcherR15() {}
80
81 R call(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6, typename util::CallTraits<P7>::TParam iP7, typename util::CallTraits<P8>::TParam iP8, typename util::CallTraits<P9>::TParam iP9, typename util::CallTraits<P10>::TParam iP10, typename util::CallTraits<P11>::TParam iP11, typename util::CallTraits<P12>::TParam iP12, typename util::CallTraits<P13>::TParam iP13, typename util::CallTraits<P14>::TParam iP14, typename util::CallTraits<P15>::TParam iP15) const
82 {
83 return doCall(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
84 }
85 bool isEquivalent(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>* iOther) const
86 {
87 return doIsEquivalent(iOther);
88 }
89
90private:
91
92 virtual R doCall(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6, typename util::CallTraits<P7>::TParam iP7, typename util::CallTraits<P8>::TParam iP8, typename util::CallTraits<P9>::TParam iP9, typename util::CallTraits<P10>::TParam iP10, typename util::CallTraits<P11>::TParam iP11, typename util::CallTraits<P12>::TParam iP12, typename util::CallTraits<P13>::TParam iP13, typename util::CallTraits<P14>::TParam iP14, typename util::CallTraits<P15>::TParam iP15) const = 0;
93 virtual bool doIsEquivalent(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>* iOther) const = 0;
94
95 DispatcherR15(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>& iOther);
96 DispatcherR15& operator=(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>& iOther);
97};
98
99
100
101/** Dispatcher for lass::util::CallbackR15 to a function or equivalent callable entinty.
102 * @internal
103 * @sa CallbackR15
104 * @author Bram de Greve [Bramz]
105 */
106template
107<
108 typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15,
109 typename FunctionType,
110 typename Enable = void
111>
112class DispatcherR15Function: public DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>
113{
114public:
115
116 typedef FunctionType TFunction;
117 typedef DispatcherR15Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, FunctionType, Enable> TSelf;
118
119 DispatcherR15Function(typename CallTraits<TFunction>::TParam iFunction):
120 function_(iFunction)
121 {
122 }
123
124 const TFunction& function() const
125 {
126 return function_;
127 }
128
129private:
130
131 R doCall(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6, typename util::CallTraits<P7>::TParam iP7, typename util::CallTraits<P8>::TParam iP8, typename util::CallTraits<P9>::TParam iP9, typename util::CallTraits<P10>::TParam iP10, typename util::CallTraits<P11>::TParam iP11, typename util::CallTraits<P12>::TParam iP12, typename util::CallTraits<P13>::TParam iP13, typename util::CallTraits<P14>::TParam iP14, typename util::CallTraits<P15>::TParam iP15) const override
132 {
133 if (!function_)
134 {
135 LASS_THROW_EX(EmptyCallback, "You've tried to call an empty CallbackR0. Can't return a value.");
136 }
137 return function_(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
138 }
139
140 bool doIsEquivalent(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>* other) const override
141 {
142 if constexpr (impl::IsEqualityComparable<TFunction>::value)
143 {
144 return other && typeid( *other ) == typeid( TSelf )
145 && static_cast<const TSelf*>(other)->function_ == function_;
146 }
147 else
148 {
149 return false;
150 }
151 }
152
153 TFunction function_;
154};
155
156
157
158#if !LASS_HAVE_LAMBDA_OPERATOR_NOT
159
160/** Dispatcher for lass::util::CallbackR0 to a callable that does not support operator!
161 * @internal
162 * @sa CallbackR0
163 * @author Bram de Greve [Bramz]
164 *
165 * With C++11, lambdas can also be used as callables. But the MSVC compiler did not support
166 * the unary ! operator. This was fixed in VS 2019 version 16.2.
167 * https://twitter.com/lunasorcery/status/1092870113374687232
168 */
169template
170<
171 typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15,
172 typename FunctionType
173>
174class DispatcherR15Function
175 <
176 R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15,
177 FunctionType,
178 typename meta::EnableIf<!HasOperatorNot<FunctionType>::value>::Type
179 >
180 : public DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>
181{
182public:
183
184 typedef FunctionType TFunction;
185
186 DispatcherR15Function(typename CallTraits<TFunction>::TParam iFunction):
187 function_(iFunction)
188 {
189 }
190
191 const TFunction& function() const
192 {
193 return function_;
194 }
195
196private:
197
198 R doCall(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6, typename util::CallTraits<P7>::TParam iP7, typename util::CallTraits<P8>::TParam iP8, typename util::CallTraits<P9>::TParam iP9, typename util::CallTraits<P10>::TParam iP10, typename util::CallTraits<P11>::TParam iP11, typename util::CallTraits<P12>::TParam iP12, typename util::CallTraits<P13>::TParam iP13, typename util::CallTraits<P14>::TParam iP14, typename util::CallTraits<P15>::TParam iP15) const override
199 {
200 return function_(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
201 }
202
203 bool doIsEquivalent(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>* /*iOther*/) const override
204 {
205 return false;
206 }
207
208 TFunction function_;
209};
210
211#endif
212
213
214
215/** Dispatcher for lass::util::CallbackR15 to an object/method pair.
216 * @internal
217 * @sa CallbackR15
218 * @author Bram de Greve [Bramz]
219 */
220template
221<
222 typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15,
223 typename ObjectPtr, typename Method
224>
225class DispatcherR15Method: public DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>
226{
227public:
228
229 typedef DispatcherR15Method<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, ObjectPtr, Method> TSelf;
230
231 DispatcherR15Method(typename CallTraits<ObjectPtr>::TParam iObject,
232 typename CallTraits<Method>::TParam iMethod):
233 object_(iObject),
234 method_(iMethod)
235 {
236 }
237
238private:
239
240 R doCall(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6, typename util::CallTraits<P7>::TParam iP7, typename util::CallTraits<P8>::TParam iP8, typename util::CallTraits<P9>::TParam iP9, typename util::CallTraits<P10>::TParam iP10, typename util::CallTraits<P11>::TParam iP11, typename util::CallTraits<P12>::TParam iP12, typename util::CallTraits<P13>::TParam iP13, typename util::CallTraits<P14>::TParam iP14, typename util::CallTraits<P15>::TParam iP15) const override
241 {
242 if (!object_ || !method_)
243 {
244 LASS_THROW_EX(EmptyCallback, "You've tried to call an empty CallbackR0. Can't return a value.");
245 }
246 return ((*object_).*method_)(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
247 }
248
249 bool doIsEquivalent(const DispatcherR15<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15>* iOther) const override
250 {
251 const TSelf* other = dynamic_cast<const TSelf*>(iOther);
252 return other && object_ == other->object_ && method_ == other->method_;
253 }
254
255 ObjectPtr object_;
256 Method method_;
257};
258
259
260
261}
262
263}
264
265}
266
267#endif // Guardian of Inclusion
268
269
270// EOF
library for template meta programming
Definition bool.h:76
general utility, debug facilities, ...
Library for Assembled Shared Sources.
Definition config.h:53