SbEventHandler< ArgType > Class Template Reference
[Basics]

Class representing an event. More...

#include <Inventor/SbEventHandler.h>

List of all members.

Public Member Functions

void operator() (ArgType arg)
void add (void(*f)(ArgType))
template<typename ClassType >
void add (ClassType &a, void(ClassType::*f)(ArgType))
bool remove (void(*f)(ArgType))
template<typename ClassType >
bool remove (ClassType &a, void(ClassType::*f)(ArgType))

Detailed Description

template<typename ArgType>
class SbEventHandler< ArgType >

Class representing an event.

An SbEventHandler encapsulates a list of "callbacks" or "delegates" that will be called when an event occurs. We generally think of events as input events, like mouseMove or keyboard, but they can be anything, like starting a computation or notifying that an object's state has changed.

The callback signature must be:

void callback(EventArg arg)
where EventArg is the template type of SbEventHandler.

All SbEventHandler callbacks must return void and have a single argument of type EventArg . This argument will generally be a structure containing information about the event and possibly methods to query additional information. In OpenInventor, all EventArg will inherit from the SbEventArg class, but it is not mandatory if you want to define your own events. In any case, EventArg must not be void

Callbacks are registered using one of the add() methods. You can register a free function, a static class method or a member class method.

EXAMPLE

SEE ALSO

SbEventArg

See related examples:

EventHandlerExample


Member Function Documentation

template<typename ArgType>
template<typename ClassType >
void SbEventHandler< ArgType >::add ( ClassType &  a,
void(ClassType::*)(ArgType)  f 
) [inline]

Add a member function callback for this event.

template<typename ArgType>
void SbEventHandler< ArgType >::add ( void(*)(ArgType)  f  )  [inline]

Add a static function callback for this event.

template<typename ArgType>
void SbEventHandler< ArgType >::operator() ( ArgType  arg  )  [inline]

Call all registered callbacks.

Parameters:
arg Argument that will be given to callback.
Warning:
Calling order of callbacks is undefined.
template<typename ArgType>
template<typename ClassType >
bool SbEventHandler< ArgType >::remove ( ClassType &  a,
void(ClassType::*)(ArgType)  f 
) [inline]

Remove a member function.

If you add the same callback several times, you must remove it several times.

Returns:
True if callback has been removed.
template<typename ArgType>
bool SbEventHandler< ArgType >::remove ( void(*)(ArgType)  f  )  [inline]

Remove a static function.

If you add the same callback several times, you must remove it several times.

Returns:
True if callback has been removed.

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

Open Inventor Toolkit reference manual, generated on 8 Apr 2021
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/