Open Lighting Architecture
0.9.6
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
ola
MultiCallback.h
Go to the documentation of this file.
1
/*
2
* This library is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU Lesser General Public
4
* License as published by the Free Software Foundation; either
5
* version 2.1 of the License, or (at your option) any later version.
6
*
7
* This library is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
* Lesser General Public License for more details.
11
*
12
* You should have received a copy of the GNU Lesser General Public
13
* License along with this library; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
*
16
* MultiCallback.h
17
* A callback which can be exectuted multiple times. When a pre-defined limit
18
* is reached, then the underlying callback is executed.
19
* Copyright (C) 2011 Simon Newton
20
*/
21
50
#ifndef INCLUDE_OLA_MULTICALLBACK_H_
51
#define INCLUDE_OLA_MULTICALLBACK_H_
52
53
#include <
ola/Callback.h
>
54
55
namespace
ola {
56
71
class
MultiCallback
:
public
BaseCallback0
<void> {
72
public
:
79
MultiCallback
(
unsigned
int
limit,
80
BaseCallback0<void>
*callback)
81
: m_count(0),
82
m_limit(limit),
83
m_callback(callback) {
84
if
(!limit) {
85
callback->Run();
86
delete
this
;
87
}
88
}
89
94
void
Run
() {
95
if
(++m_count == m_limit) {
96
m_callback->Run();
97
delete
this
;
98
}
99
}
100
101
private
:
102
unsigned
int
m_count;
103
unsigned
int
m_limit;
104
BaseCallback0<void>
*m_callback;
105
};
106
113
inline
BaseCallback0<void>
*
NewMultiCallback
(
114
unsigned
int
limit,
115
BaseCallback0<void>
*callback) {
116
return
new
MultiCallback
(limit, callback);
117
}
119
}
// namespace ola
120
#endif // INCLUDE_OLA_MULTICALLBACK_H_
Generated on Fri Jul 3 2015 15:58:45 for Open Lighting Architecture by
1.8.1.2