Library of Assembled Shared Sources
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 Mon Oct 6 22:51:38 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-2011 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 std::remove( callbacks_.begin(), callbacks_.end(), iCallback );
144 }
145
146 /** pop a callback from the list of callbacks
147 */
148 void pop( TCallback& iCallback )
149 {
150 iCallback = callbacks_.back();
151 callbacks_.pop_back();
152 }
153
154 /** add a callback to the list of callbacks to be dispatched
155 */
156 TSelf& operator += ( const TCallback& iCallback )
157 {
158 callbacks_.push_back(iCallback);
159 return *this;
160 }
161
162 /** removes a callback from the list of callbacks to be dispatched
163 */
164 TSelf& operator -= ( const TCallback& iCallback )
165 {
166 remove(iCallback);
167 return *this;
168 }
169
170 /** the number of callbacks that will be dispatched
171 */
172 size_t size() const
173 {
174 return callbacks_.size();
175 }
176
177 /** THE operator. Executes the multi-callback.
178 */
179 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
180 {
181 call(iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
182 }
183 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
184 {
185 size_t nrCallbacks = callbacks_.size();
186 for (size_t i=0;i<nrCallbacks;++i)
187 callbacks_[i](iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
188 }
189 /** retrieve a callback */
190 const TCallback& operator[](size_t index) const
191 {
192 return callbacks_.at(index);
193 }
194
195
196
197 // METHODS
198
199 /** Reset to empty callback.
200 */
201 void reset()
202 {
203 callbacks_.clear();
204 }
205
206 /** Returns true if no callback dispatcher is assigned to this object.
207 */
208 bool isEmpty() const
209 {
210 return callbacks_.size()==0;
211 }
212
213 /** return this->isEmpty()
214 */
215 bool operator!() const
216 {
217 return isEmpty();
218 }
219
220 /** return !this->isEmpty())
221 */
222 explicit operator bool() const
223 {
224 return !isEmpty();
225 }
226
227 /** Swaps the dispatchers of this multi_callback with the dispatchers of another.
228 */
229 void swap(TSelf& iOther)
230 {
231 callbacks_.swap(iOther.callbacks_);
232 }
233
234 /** return true if two callbacks call the same function/method,
235 * NEEDS RTTI!
236 */
237 bool operator==(const TSelf& iOther) const
238 {
239 size_t nrCallbacks = callbacks_.size();
240 if (nrCallbacks != iOther.callbacks_.size())
241 return false;
242 for (size_t i=0;i<nrCallbacks;++i)
243 if (callbacks_[i]!=iOther.callbacks_[i])
244 return false;
245 return true;
246 }
247private:
248 std::vector<TCallback> callbacks_;
249};
250
251}
252}
253
254#endif
255
256// EOF
general utility, debug facilities, ...
Library for Assembled Shared Sources.
Definition config.h:53