Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Functions
MultiCallback.h File Reference

Detailed Description

A callback which can be executed multiple times. When a pre-defined limit is reached, then the underlying callback is executed.

Example
// Calls DoSomething() for each Port and runs the on_complete callback once
// each port's callback has run.
void DoSomethingForAllPorts(const vector<OutputPort> &ports,
SomethingCalback *on_complete) {
// This will call on_complete once it itself has been Run ports.size()
// times.
BaseCallback0<void> *multi_callback = NewMultiCallback( ports.size(),
NewSingleCallback(this, &SomethingComplete,
on_complete));
vector<OutputPort*>::iterator iter;
for (iter = output_ports.begin(); iter != output_ports.end(); ++iter) {
(*iter)->DoSomething(multi_callback);
}
}

Go to the source code of this file.

Classes

class  ola::MultiCallback
 The MultiCallback class takes a limit & a callback. When the Run() method is called limit times, the callback is executed and the MultiCallback object deleted. More...

Namespaces

namespace  ola
 The namespace containing all OLA symbols.

Functions

BaseCallback0< void > * ola::NewMultiCallback (unsigned int limit, BaseCallback0< void > *callback)
 A helper function to create a new MultiCallback.