Library of Assembled Shared Sources
 
Loading...
Searching...
No Matches
multi_callback_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 multi_callback_x.tmpl.h
5 * by param_expander.py on Fri Aug 14 16:06:09 2026.
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-2026 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#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_MULTI_CALLBACK_15_H
53#define LASS_GUARDIAN_OF_INCLUSION_UTIL_MULTI_CALLBACK_15_H
54
55/** @defgroup Callback Callback
56 * @brief library to group generalized callback functions
57 * @date 2009
58 * @author Tom De Muer (contact: tom@cocamware.com)
59 *
60 */
61
62#include <algorithm>
63#include "callback_15.h"
64
65namespace lass
66{
67namespace util
68{
69
70template
71<
72 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>
74struct MultiCallback15
75{
76 typedef MultiCallback15 TSelf;
77 typedef Callback15<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> TCallback;
78
79 /** Default constructor, construct empty callback list.
80 */
81 MultiCallback15()
82 {
83 }
84
85 /** Constructor: construct multi callback with a single callback.
86 */
87 MultiCallback15(const TCallback& iCallback)
88 {
89 callbacks_.push_back(iCallback);
90 }
91
92 /** Constructor: construct multi callback with a two callbacks.
93 */
94 MultiCallback15(const TCallback& iCallback1, const TCallback& iCallback2)
95 {
96 callbacks_.push_back(iCallback1);
97 callbacks_.push_back(iCallback2);
98 }
99
100 /** copy constructor
101 */
102 MultiCallback15(const TSelf& iOther):
103 callbacks_(iOther.callbacks_)
104 {
105 }
106
107 /** move constructor
108 */
109 MultiCallback15(TSelf&& iOther) noexcept:
110 callbacks_(std::move(iOther.callbacks_))
111 {
112 }
113
114 /** assignment operator (also usable for conversion)
115 */
116 TSelf& operator=(const TSelf& iOther)
117 {
118 callbacks_ = std::move(iOther.callbacks_);
119 return *this;
120 }
121
122 /** move assignment operator
123 */
124 TSelf& operator=(TSelf&& iOther) noexcept
125 {
126 TSelf temp(iOther);
127 swap(temp);
128 return *this;
129 }
130
131 /** add a callback to the list of callbacks to be dispatched
132 */
133 void add( const TCallback& iCallback )
134 {
135 callbacks_.push_back(iCallback);
136 }
137
138 /** removes a callback from the list of callbacks to be dispatched,
139 * callbacks are tested for equivalence.
140 */
141 void remove( const TCallback& iCallback )
142 {
143 auto end = std::remove( callbacks_.begin(), callbacks_.end(), iCallback );
144 callbacks_.erase( end, callbacks_.end() );
145 }
146
147 /** pop a callback from the list of callbacks
148 */
149 void pop( TCallback& iCallback )
150 {
151 iCallback = callbacks_.back();
152 callbacks_.pop_back();
153 }
154
155 /** add a callback to the list of callbacks to be dispatched
156 */
157 TSelf& operator += ( const TCallback& iCallback )
158 {
159 callbacks_.push_back(iCallback);
160 return *this;
161 }
162
163 /** removes a callback from the list of callbacks to be dispatched
164 */
165 TSelf& operator -= ( const TCallback& iCallback )
166 {
167 remove(iCallback);
168 return *this;
169 }
170
171 /** the number of callbacks that will be dispatched
172 */
173 size_t size() const
174 {
175 return callbacks_.size();
176 }
177
178 /** THE operator. Executes the multi-callback.
179 */
180 void 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, 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
181 {
182 call(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
183 }
184 void 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
185 {
186 size_t nrCallbacks = callbacks_.size();
187 for (size_t i=0;i<nrCallbacks;++i)
188 callbacks_[i](iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
189 }
190 /** retrieve a callback */
191 const TCallback& operator[](size_t index) const
192 {
193 return callbacks_.at(index);
194 }
195
196
197
198 // METHODS
199
200 /** Reset to empty callback.
201 */
202 void reset()
203 {
204 callbacks_.clear();
205 }
206
207 /** Returns true if no callback dispatcher is assigned to this object.
208 */
209 bool isEmpty() const
210 {
211 return callbacks_.size()==0;
212 }
213
214 /** return this->isEmpty()
215 */
216 bool operator!() const
217 {
218 return isEmpty();
219 }
220
221 /** return !this->isEmpty())
222 */
223 explicit operator bool() const
224 {
225 return !isEmpty();
226 }
227
228 /** Swaps the dispatchers of this multi_callback with the dispatchers of another.
229 */
230 void swap(TSelf& iOther)
231 {
232 callbacks_.swap(iOther.callbacks_);
233 }
234
235 /** return true if two callbacks call the same function/method,
236 * NEEDS RTTI!
237 */
238 bool operator==(const TSelf& iOther) const
239 {
240 size_t nrCallbacks = callbacks_.size();
241 if (nrCallbacks != iOther.callbacks_.size())
242 return false;
243 for (size_t i=0;i<nrCallbacks;++i)
244 if (callbacks_[i]!=iOther.callbacks_[i])
245 return false;
246 return true;
247 }
248private:
249 std::vector<TCallback> callbacks_;
250};
251
252}
253}
254
255#endif
256
257// EOF
general utility, debug facilities, ...
Library for Assembled Shared Sources.
Definition config.h:53