跳转到主要内容

GenericCallback

touchgfx/Callback.hpp

GenericCallback is the base class for callbacks. The reason this base class exists, is that a normal Callback requires the class type where the callback function resides to be known. This is problematic for ie. framework widgets like AbstractButton, on which it should be possible to register a callback on object types that are user-specific and thus unknown to AbstractButton. This is solved by having AbstractButton contain a pointer to a GenericCallback instead. This pointer must then be initialized to point on an instance of Callback, created by the user, which is initialized with the appropriate object type.

Template Parameters:

  • T1 The type of the first argument in the member function, or void if none.
  • T2 The type of the second argument in the member function, or void if none.
  • T3 The type of the third argument in the member function, or void if none.

See: Callback

Note: As with Callback, this class exists in four versions to support callback functions taking zero, one, two or three arguments.

Public Functions

virtual voidexecute(T1 val1, T2 val2, T3 val3) =0
Calls the member function.
virtual boolisValid() const =0
Function to check whether the Callback has been initialized with values.
virtual ~GenericCallback()
Finalizes an instance of the GenericCallback class.

Public Functions Documentation

execute

virtual void execute(T1val1 ,=0
T2val2 ,=0
T3val3=0
)=0

Calls the member function.

Do not call execute unless isValid() returns true (ie. a pointer to the object and the function has been set).

Parameters:
val1This value will be passed as the first argument in the function call.
val2This value will be passed as the second argument in the function call.
val3This value will be passed as the third argument in the function call.

Reimplemented by: touchgfx::Callback::execute, touchgfx::Callback::execute, touchgfx::Callback::execute

isValid

virtual bool isValid()const =0

Function to check whether the Callback has been initialized with values.

Returns:

true If the callback is valid (i.e. safe to call execute).

Reimplemented by: touchgfx::Callback::isValid, touchgfx::Callback::isValid, touchgfx::Callback::isValid

~GenericCallback

virtual ~GenericCallback()

Finalizes an instance of the GenericCallback class.