poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_Event Class Reference

A simple event class. More...

#include <poser/core/event.h>

Public Member Functions

PSC_EventPSC_Event_create (void *sender)
 PSC_Event constructor.
 
void PSC_Event_register (PSC_Event *self, void *receiver, PSC_EventHandler handler, int id)
 Register an event handler.
 
void PSC_Event_unregister (PSC_Event *self, void *receiver, PSC_EventHandler handler, int id)
 Unregister an event handler.
 
void PSC_Event_raise (PSC_Event *self, int id, void *args)
 Raise an event.
 
void PSC_Event_destroy (PSC_Event *self)
 PSC_Event destructor.
 

Detailed Description

A simple event class.

Events can be raised and subscribed to. The class emitting an event should own it and provide an accessor method for consumers to subscribe to it.

When an event is raised, all subscribers are called directly. No mechanism to cross threads is offered, so always use functions/objects wired by events on the same thread.

Member Function Documentation

◆ PSC_Event_create()

PSC_Event * PSC_Event_create ( void *  sender)

PSC_Event constructor.

Parameters
senderthe object owning the event, or NULL for static classes
Returns
a newly created event

◆ PSC_Event_destroy()

void PSC_Event_destroy ( PSC_Event self)

PSC_Event destructor.

Parameters
selfthe PSC_Event

◆ PSC_Event_raise()

void PSC_Event_raise ( PSC_Event self,
int  id,
void *  args 
)

Raise an event.

Called by the event owner to notify all subscribers that the event occured. Only handlers with the same identifier will be called.

Parameters
selfthe PSC_Event
idoptional identifier to be matched, use 0 if not applicable
argsoptional event args to pass to the handler(s)

◆ PSC_Event_register()

void PSC_Event_register ( PSC_Event self,
void *  receiver,
PSC_EventHandler  handler,
int  id 
)

Register an event handler.

Parameters
selfthe PSC_Event
receiverthe object that should receive the event
handlerthe handler to be called
idoptional identifier to be matched, use 0 if not applicable

◆ PSC_Event_unregister()

void PSC_Event_unregister ( PSC_Event self,
void *  receiver,
PSC_EventHandler  handler,
int  id 
)

Unregister an event handler.

When this is called with the exact same parameters as PSC_Event_register(), it removes the event handler from the event again.

Parameters
selfthe PSC_Event
receiverthe object that should receive the event
handlerthe handler to be called
idoptional identifier to be matched, use 0 if not applicable

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