Library of Assembled Shared Sources
callback_r_11.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 callback_r_x.tmpl.h
5 * by param_expander.py on Tue Oct 7 01:22:01 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
51
52/** @class lass::util::CallbackR11
53 * @ingroup Callback
54 * @brief callback with 11 parameter11 and with returnvalue.
55 * @date 2002
56 * @author Bram de Greve [Bramz] (contact: bram@cocamware.com)
57 *
58 * It's a single object that can hold a reference to a free function or an
59 * object/(const) method pair. Once the callback is constructed, it works
60 * completely transparent. All it shows to the client is a function that
61 * takes 11 parameter(s) and gives a returnvalue.
62 */
63
64
65
66#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_R_11_H
67#define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_R_11_H
68
69
70
71// --- OLD INTERFACES ----------------------------------------------------------
72
73#include "util_common.h"
74#include "shared_ptr.h"
75#include "callback_common.h"
77
78
79
80
81// --- NEW INTERFACES ----------------------------------------------------------
82
83namespace lass
84{
85namespace util
86{
87
88
89// THE CALLBACK:
90// This is the actuall class you use to hold callbacks:
91
92template
93<
94 typename R,
95 typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11
96>
98{
99public:
100
102 typedef SharedPtr< impl::DispatcherR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> > TDispatcherPtr;
103
104 // STRUCTORS
105
106 /** Default constructor, construct empty callback.
107 */
109 {
110 }
111
112 /** Construct function callback
113 */
114 template <typename FunctionType>
115 CallbackR11(FunctionType iFunction):
116 dispatcher_(new impl::DispatcherR11Function<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, FunctionType>(iFunction))
117 {
118 }
119
120 /** Construct object/method callback.
121 */
122 template <typename ObjectPtr, typename Method>
123 CallbackR11(ObjectPtr iObject, Method iMethod):
124 dispatcher_(new impl::DispatcherR11Method<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, ObjectPtr, Method>(iObject, iMethod))
125 {
126 }
127
128 /** copy constructor
129 */
130 CallbackR11(const TSelf& iOther):
131 dispatcher_(iOther.dispatcher_)
132 {
133 }
134
135 /** move constructor
136 */
137 CallbackR11(TSelf&& iOther) noexcept:
138 dispatcher_(std::move(iOther.dispatcher_))
139 {
140 }
141
142
143 // OPERATORS
144
145 /** assignment operator
146 */
147 TSelf& operator=(const TSelf& iOther)
148 {
149 TSelf temp(iOther);
150 swap(temp);
151 return *this;
152 }
153
154 /** assignment operator
155 */
156 TSelf& operator=(TSelf&& iOther) noexcept
157 {
158 dispatcher_ = std::move(iOther.dispatcher_);
159 return *this;
160 }
161
162 /** THE operator. Executes the callback.
163 */
164 R operator()(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) const
165 {
166 if (isEmpty())
167 {
168 LASS_THROW_EX(EmptyCallback, "You've tried to call an empty CallbackR11. Can't return a value.");
169 }
170 return dispatcher_->call(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11);
171 }
172
173
174 // METHODS
175
176 /** Reset to empty callback.
177 */
178 void reset()
179 {
180 dispatcher_.reset();
181 }
182
183 /** Returns true if no callback dispatcher is assigned to this object.
184 */
185 bool isEmpty() const
186 {
187 return dispatcher_.isEmpty();
188 }
189
190 /** return this->isEmpty()
191 */
192 bool operator!() const
193 {
194 return dispatcher_.isEmpty();
195 }
196
197 /** return !this->isEmpty())
198 */
199 explicit operator bool() const
200 {
201 return !dispatcher_.isEmpty();
202 }
203
204 /** Swaps the dispatcher of this callback with the dispatcher of another.
205 */
206 void swap(TSelf& iOther)
207 {
208 dispatcher_.swap(iOther.dispatcher_);
209 }
210
211 /** return true if two callbacks call the same function/method,
212 * NEEDS RTTI!
213 */
214 bool operator==(const TSelf& iOther) const
215 {
216 if (dispatcher_ == iOther.dispatcher_)
217 {
218 return true;
219 }
220 return dispatcher_ && dispatcher_->isEquivalent(iOther.dispatcher_.get());
221 }
222
223 const TDispatcherPtr& dispatcher() const
224 {
225 return dispatcher_;
226 }
227
228private:
229
230 TDispatcherPtr dispatcher_;
231};
232
233
234
235/** return true if two callbacks are different
236 * @relates CallbackR11
237 */
238template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11>
243
244
245/** make a CallbackR11 from a function
246 * @relates CallbackR11
247 */
248template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11> inline
249CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> makeCallback(R (*iFunction)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))
250{
252}
253
254
255
256/** make a CallbackR11 from a function
257 * @relates CallbackR11
258 */
259template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11> inline
264
265
266
267/** make a CallbackR11 from a object and method
268 * @relates CallbackR11
269 */
270template <typename ObjectPtr, typename Object, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11> inline
271CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> makeCallback(ObjectPtr iObject, R (Object::*iMethod)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))
272{
274}
275
276
277
278/** make a CallbackR11 from a object and const method
279 * @relates CallbackR11
280 */
281template <typename ObjectPtr, typename Object, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11> inline
282CallbackR11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> makeCallback(ObjectPtr iObject, R (Object::*iMethod)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) const)
283{
285}
286
287
288
289}
290
291}
292
293#define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_R11
294#ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H
296#endif
297
298#endif // Guardian of Inclusion
299
300// EOF
CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > makeCallback(ObjectPtr iObject, R(Object::*iMethod)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) const)
make a CallbackR11 from a object and const method
CallbackR11(FunctionType iFunction)
Construct function callback.
CallbackR11(ObjectPtr iObject, Method iMethod)
Construct object/method callback.
CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > makeCallback(R(*iFunction)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))
make a CallbackR11 from a function
const CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > & makeCallback(const CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > &iCallback)
make a CallbackR11 from a function
void swap(TSelf &iOther)
Swaps the dispatcher of this callback with the dispatcher of another.
R operator()(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) const
THE operator.
bool operator==(const TSelf &iOther) const
return true if two callbacks call the same function/method, NEEDS RTTI!
CallbackR11()
Default constructor, construct empty callback.
CallbackR11(TSelf &&iOther) noexcept
move constructor
TSelf & operator=(TSelf &&iOther) noexcept
assignment operator
bool operator!=(const CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > &iA, const CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > &iB)
return true if two callbacks are different
CallbackR11< R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 > makeCallback(ObjectPtr iObject, R(Object::*iMethod)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))
make a CallbackR11 from a object and method
TSelf & operator=(const TSelf &iOther)
assignment operator
bool isEmpty() const
Returns true if no callback dispatcher is assigned to this object.
CallbackR11(const TSelf &iOther)
copy constructor
bool operator!() const
return this->isEmpty()
void reset()
Reset to empty callback.
general utility, debug facilities, ...
Library for Assembled Shared Sources.
Definition config.h:53