ScummVM API documentation
Common::CallbackBridge< T, OS, S > Class Template Reference

#include <callback.h>

Inheritance diagram for Common::CallbackBridge< T, OS, S >:
Common::BaseCallback< S >

Public Member Functions

 CallbackBridge (T *object, TCallbackMethod method, BaseCallback< OS > *outerCallback)
 
void operator() (S data)
 

Detailed Description

template<class T, typename OS, typename S = void *>
class Common::CallbackBridge< T, OS, S >

CallbackBridge<T, OS, S> allows you to chain callbacks.

CallbackBridge keeps a pointer to BaseCallback<OS>. When its operator() is called, it passes this pointer along with the actual data (of type <S>) to the method of <T> class.

This is needed when you have to call a callback only when your own callback is called. So, your callback is "inner" and the other one is "outer".

CallbackBridge implements the "inner" one and calls the method you wanted. It passes the "outer", so you can call it from your method. You can ignore it, but probably there is no point in using CallbackBridge then.

So, if you receive a BaseCallback<SomeClass> callback and you want to call it from your MyClass::myMethod method, you should create CallbackBridge<MyClass, SomeClass, S>, where <S> is the data type you want to receive in MyClass::myMethod.

You can create it in the following way: new Callback<MyClass, SomeClass, AnotherClass>( pointerToMyClassObject, &MyClass::myMethod, outerCallback ) where outerCallback is BaseCallback<SomeClass> and myMethod is: void MyClass::myMethod(BaseCallback<SomeClass> *, AnotherClass)

Member Function Documentation

◆ operator()()

template<class T , typename OS , typename S = void *>
void Common::CallbackBridge< T, OS, S >::operator() ( data)
inlinevirtual

Type of the object passed to the operator.

Implements Common::BaseCallback< S >.


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