Open Lighting Architecture: ola::CallbackRunner< CallbackClass > Class Template Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::CallbackRunner< CallbackClass > Class Template Reference
Callback Helpers

## Detailed Description

template<typename CallbackClass>
class ola::CallbackRunner< CallbackClass >

Automatically execute a callback when it goes out of scope.

Template Parameters

  CallbackClass | An class which has a Run() method.

This is useful if the function or method has multiple return points and you need to ensure that the callback is always executed before the function returns. It's most useful for handling RPCs.

Example
  int Foo(MyCallback *callback) {
  CallbackRunner runner(callback);
  if (...) {
  // do something here.
  return 1;
  } else {
  if (...) {
  // do something here.
  return 2;
  } else {
  // do something here.
  return 3;
  }
  }
  }
  ola::CallbackRunner::CallbackRunner
  CallbackRunner(CallbackClass *callback)
  Definition CallbackRunner.h:88

## Public Member Functions
| CallbackRunner (CallbackClass *callback)
| ~CallbackRunner ()

## Constructor & Destructor Documentation

## ◆ CallbackRunner()

template<typename CallbackClass>

ola::CallbackRunner< CallbackClass >::CallbackRunner | ( | CallbackClass * | callback | ) |
| inlineexplicit

Construct a new CallbackRunner.

Parameters

  callback | the Callback to execute.

## ◆ ~CallbackRunner()

template<typename CallbackClass>

ola::CallbackRunner< CallbackClass >::~CallbackRunner | ( |  | ) |
| inline

Destructor, this executes the callback.

The documentation for this class was generated from the following file:

- include/ola/CallbackRunner.h