1 // This file was GENERATED by command:
2 // pump.py callback.h.pump
3 // DO NOT EDIT BY HAND!!!
7 // Copyright 2014 The Chromium Authors. All rights reserved.
8 // Use of this source code is governed by a BSD-style license that can be
9 // found in the LICENSE file.
11 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_
12 #define MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_
14 #include "mojo/public/cpp/bindings/lib/callback_internal.h"
15 #include "mojo/public/cpp/bindings/lib/shared_ptr.h"
16 #include "mojo/public/cpp/bindings/lib/template_util.h"
20 template <typename Sig
>
24 class Callback
<void()> {
27 virtual ~Runnable() {}
28 virtual void Run() const = 0;
33 // The Callback assumes ownership of |runnable|.
34 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
36 // Any class that is copy-constructable and has a compatible Run method may
37 // be adapted to a Callback using this constructor.
38 template <typename Sink
>
39 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
46 bool is_null() const {
51 template <typename Sink
>
52 struct Adapter
: public Runnable
{
53 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
54 virtual void Run() const MOJO_OVERRIDE
{
60 internal::SharedPtr
<Runnable
> sink_
;
63 template <typename A1
>
64 class Callback
<void(A1
)> {
67 virtual ~Runnable() {}
69 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
) const = 0;
74 // The Callback assumes ownership of |runnable|.
75 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
77 // Any class that is copy-constructable and has a compatible Run method may
78 // be adapted to a Callback using this constructor.
79 template <typename Sink
>
80 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
82 void Run(typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
) const {
84 sink_
->Run(internal::Forward(a1
));
87 bool is_null() const {
92 template <typename Sink
>
93 struct Adapter
: public Runnable
{
94 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
96 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
) const
98 sink
.Run(internal::Forward(a1
));
103 internal::SharedPtr
<Runnable
> sink_
;
106 template <typename A1
, typename A2
>
107 class Callback
<void(A1
, A2
)> {
110 virtual ~Runnable() {}
112 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
113 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
) const = 0;
118 // The Callback assumes ownership of |runnable|.
119 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
121 // Any class that is copy-constructable and has a compatible Run method may
122 // be adapted to a Callback using this constructor.
123 template <typename Sink
>
124 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
127 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
128 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
) const {
131 internal::Forward(a1
),
132 internal::Forward(a2
));
135 bool is_null() const {
140 template <typename Sink
>
141 struct Adapter
: public Runnable
{
142 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
144 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
145 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
) const
148 internal::Forward(a1
),
149 internal::Forward(a2
));
154 internal::SharedPtr
<Runnable
> sink_
;
157 template <typename A1
, typename A2
, typename A3
>
158 class Callback
<void(A1
, A2
, A3
)> {
161 virtual ~Runnable() {}
163 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
164 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
165 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
) const = 0;
170 // The Callback assumes ownership of |runnable|.
171 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
173 // Any class that is copy-constructable and has a compatible Run method may
174 // be adapted to a Callback using this constructor.
175 template <typename Sink
>
176 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
179 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
180 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
181 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
) const {
184 internal::Forward(a1
),
185 internal::Forward(a2
),
186 internal::Forward(a3
));
189 bool is_null() const {
194 template <typename Sink
>
195 struct Adapter
: public Runnable
{
196 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
198 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
199 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
200 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
) const
203 internal::Forward(a1
),
204 internal::Forward(a2
),
205 internal::Forward(a3
));
210 internal::SharedPtr
<Runnable
> sink_
;
213 template <typename A1
, typename A2
, typename A3
, typename A4
>
214 class Callback
<void(A1
, A2
, A3
, A4
)> {
217 virtual ~Runnable() {}
219 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
220 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
221 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
222 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
) const = 0;
227 // The Callback assumes ownership of |runnable|.
228 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
230 // Any class that is copy-constructable and has a compatible Run method may
231 // be adapted to a Callback using this constructor.
232 template <typename Sink
>
233 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
236 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
237 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
238 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
239 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
) const {
242 internal::Forward(a1
),
243 internal::Forward(a2
),
244 internal::Forward(a3
),
245 internal::Forward(a4
));
248 bool is_null() const {
253 template <typename Sink
>
254 struct Adapter
: public Runnable
{
255 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
257 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
258 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
259 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
260 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
) const
263 internal::Forward(a1
),
264 internal::Forward(a2
),
265 internal::Forward(a3
),
266 internal::Forward(a4
));
271 internal::SharedPtr
<Runnable
> sink_
;
274 template <typename A1
, typename A2
, typename A3
, typename A4
, typename A5
>
275 class Callback
<void(A1
, A2
, A3
, A4
, A5
)> {
278 virtual ~Runnable() {}
280 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
281 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
282 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
283 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
284 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
) const = 0;
289 // The Callback assumes ownership of |runnable|.
290 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
292 // Any class that is copy-constructable and has a compatible Run method may
293 // be adapted to a Callback using this constructor.
294 template <typename Sink
>
295 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
298 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
299 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
300 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
301 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
302 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
) const {
305 internal::Forward(a1
),
306 internal::Forward(a2
),
307 internal::Forward(a3
),
308 internal::Forward(a4
),
309 internal::Forward(a5
));
312 bool is_null() const {
317 template <typename Sink
>
318 struct Adapter
: public Runnable
{
319 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
321 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
322 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
323 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
324 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
325 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
) const
328 internal::Forward(a1
),
329 internal::Forward(a2
),
330 internal::Forward(a3
),
331 internal::Forward(a4
),
332 internal::Forward(a5
));
337 internal::SharedPtr
<Runnable
> sink_
;
340 template <typename A1
, typename A2
, typename A3
, typename A4
, typename A5
,
342 class Callback
<void(A1
, A2
, A3
, A4
, A5
, A6
)> {
345 virtual ~Runnable() {}
347 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
348 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
349 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
350 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
351 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
352 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
) const = 0;
357 // The Callback assumes ownership of |runnable|.
358 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
360 // Any class that is copy-constructable and has a compatible Run method may
361 // be adapted to a Callback using this constructor.
362 template <typename Sink
>
363 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
366 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
367 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
368 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
369 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
370 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
371 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
) const {
374 internal::Forward(a1
),
375 internal::Forward(a2
),
376 internal::Forward(a3
),
377 internal::Forward(a4
),
378 internal::Forward(a5
),
379 internal::Forward(a6
));
382 bool is_null() const {
387 template <typename Sink
>
388 struct Adapter
: public Runnable
{
389 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
391 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
392 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
393 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
394 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
395 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
396 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
) const
399 internal::Forward(a1
),
400 internal::Forward(a2
),
401 internal::Forward(a3
),
402 internal::Forward(a4
),
403 internal::Forward(a5
),
404 internal::Forward(a6
));
409 internal::SharedPtr
<Runnable
> sink_
;
412 template <typename A1
, typename A2
, typename A3
, typename A4
, typename A5
,
413 typename A6
, typename A7
>
414 class Callback
<void(A1
, A2
, A3
, A4
, A5
, A6
, A7
)> {
417 virtual ~Runnable() {}
419 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
420 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
421 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
422 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
423 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
424 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
,
425 typename
internal::Callback_ParamTraits
<A7
>::ForwardType a7
) const = 0;
430 // The Callback assumes ownership of |runnable|.
431 explicit Callback(Runnable
* runnable
) : sink_(runnable
) {}
433 // Any class that is copy-constructable and has a compatible Run method may
434 // be adapted to a Callback using this constructor.
435 template <typename Sink
>
436 Callback(const Sink
& sink
) : sink_(new Adapter
<Sink
>(sink
)) {}
439 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
440 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
441 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
442 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
443 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
444 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
,
445 typename
internal::Callback_ParamTraits
<A7
>::ForwardType a7
) const {
448 internal::Forward(a1
),
449 internal::Forward(a2
),
450 internal::Forward(a3
),
451 internal::Forward(a4
),
452 internal::Forward(a5
),
453 internal::Forward(a6
),
454 internal::Forward(a7
));
457 bool is_null() const {
462 template <typename Sink
>
463 struct Adapter
: public Runnable
{
464 explicit Adapter(const Sink
& sink
) : sink(sink
) {}
466 typename
internal::Callback_ParamTraits
<A1
>::ForwardType a1
,
467 typename
internal::Callback_ParamTraits
<A2
>::ForwardType a2
,
468 typename
internal::Callback_ParamTraits
<A3
>::ForwardType a3
,
469 typename
internal::Callback_ParamTraits
<A4
>::ForwardType a4
,
470 typename
internal::Callback_ParamTraits
<A5
>::ForwardType a5
,
471 typename
internal::Callback_ParamTraits
<A6
>::ForwardType a6
,
472 typename
internal::Callback_ParamTraits
<A7
>::ForwardType a7
) const
475 internal::Forward(a1
),
476 internal::Forward(a2
),
477 internal::Forward(a3
),
478 internal::Forward(a4
),
479 internal::Forward(a5
),
480 internal::Forward(a6
),
481 internal::Forward(a7
));
486 internal::SharedPtr
<Runnable
> sink_
;
489 typedef Callback
<void()> Closure
;
493 #endif // MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_