PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFYHandler
Class which manages handlers.
#include <SFYHandler.h.hpp>
class SFYHandler;
SFMTYPEDEFCLASS(SFYHandler)

Collaboration diagram

 Collaboration diagram of SFYHandlerClass

Description

This class manages a list of handlers. Some functions of this class are used only in the SFYDistributer class and the SFYResponder class and will not be used directly in the applet development.

Reference

Handler | SFYDistributer | SFYResponder | SFYApplication

Member

Types
HandlerSPP
Prototype of the handler function.
RuleRec
Structure that represents the handler of a handler function and a reference value.

SFYHandler::HandlerSPP
Prototype of the handler function.
typedef Bool(* SFYHandler::HandlerSPP)(SFYResponderPtr invoker, SFXEventConstRef event, VoidPtr reference)
SFMTYPEDEFTYPE(SFYHandler::HandlerSPP)

Description

This is the prototype of the handler function used in the SFYDistributer, SFYResponder, or SFYApplication class.

First argument: the responder that calls this handler function, second argument: the event, third argument: reference value.

Reference

SFYDistributer | SFYResponder | SFYApplication | SFYDistributer::RegisterHandler | SFYResponder::RegisterHandler | SFYApplication::RegisterHandler


SFYHandler::RuleRec
Structure that represents the handler of a handler function and a reference value.
typedef Bool (*HandlerSPP)(SFYResponderPtr invoker, SFXEventConstRef event, VoidPtr reference);
SFMTYPEDEFTYPE(HandlerSPP)
SFMTYPEDEFSTRUCT(RuleRec)
struct RuleRec {
    HandlerSPP    spp;          // handler function
    VoidPtr       reference;    // reference value
};

Description

This structure is used when calling the SFYDistributer::RegisterHandler, SFYResponder::RegisterHandler, or SFYApplication::RegisterHandler function.

Example

The code to register more than one handler at a time is as follows:

static SFXEventRange::AtomRecConst range[] = {
    {      SFEVT_KEY,       SFEVT_KEY,   SFP16_BEGIN,     SFP16_END},
    {SFEVT_KEY_PRESS, SFEVT_KEY_PRESS,   SFP16_BEGIN,     SFP16_END},
    {     SFEVT_KEY_RELEASE,      SFEVT_KEY_RELEASE,   SFP16_BEGIN,     SFP16_END}
};
SFYHandler::RuleRec rule[lengthof(range)];
SFCError error;

rule[0].spp = XANDLER_FUNCTION(OnKey);
rule[0].reference = this;
rule[1].spp = XANDLER_FUNCTION(OnKeyPress);
rule[1].reference = this;
rule[2].spp = XANDLER_FUNCTION(OnKeyRelease);
rule[2].reference = this;

error = RegisterHandler(atomic_cast(range), rule, lengthof(range));

Reference

SFYDistributer::RegisterHandler | SFYResponder::RegisterHandler | SFYApplication::RegisterHandler