observer.h File Reference

Simple notifier for the subject/observer pattern (interface). More...

#include <struct/list.h>

Go to the source code of this file.

Data Structures

struct  Observer
 Here's a simple example: More...

Typedefs

typedef struct Observer Observer
 Here's a simple example:

Functions

void observer_Subscribe (Subject *subject, Observer *observer)
 Aggiunge un Observer all'insieme.
void observer_Unsubscribe (Subject *subject, Observer *observer)
 Rimuove un Observer dall'insieme.
void observer_notify (Subject *subject, int event_id, void *param)
 per tutti gli elementi nel set notifica l'evento, chiamando la relativa funzione event

Detailed Description

Simple notifier for the subject/observer pattern (interface).

Version:
Id
observer.h 2506 2009-04-15 08:29:07Z duplo
Author:
Bernie Innocenti <bernie@codewiz.org>

Definition in file observer.h.


Typedef Documentation

typedef struct Observer Observer

Here's a simple example:

 Subject kbd_driver;

 Observer kbd_observer;

 void key_pressed(int event, void *_param)
 {
     char *param = (char *)_param;

     if (event == EVENT_KBD_PRESSED)
         printf("You pressed %c\n", *param);
 }

 void register_kbd_listener(void)
 {
     observer_SetEvent(&kbd_observer, key_pressed);
     observer_Subscribe(&kbd_driver, &kbd_observer);
 }