BeRTOS
Data Structures | Defines | Typedefs | Functions
dnotifier.h File Reference

Notifier obj (interface). More...

#include <cfg/debug.h>
#include <dt/dtag.h>
#include <struct/list.h>

Go to the source code of this file.

Data Structures

struct  DNotifier
 Base object for receive and forward messages. More...
struct  DFilterMap
 Map for messages. More...
struct  DFilter
 A filter is an interface between two notifier. More...

Defines

#define DCONNECT(src, tgt, map, opt)
 Macro that connect src notifier to tgt using map and passing opt for filtering option.

Typedefs

typedef unsigned int dfilter_mask_t
 Type for filter-mask checking.

Functions

void filter_init (DFilter *f, const DFilterMap *map, bool masked, DNotifier *source, DNotifier *target)
 Filter init.
void filter_update (DFilter *f, dtag_t tag, dval_t val)
 Filter update function without masking capabilities.
void filter_mask_update (DFilter *f, dtag_t tag, dval_t val)
 Filter update function with masking capabilities.
void notifier_init (DNotifier *n)
 Notifier init.
void dnotify (DNotifier *target, dtag_t tag, dval_t val)
 Macro to notify the target object.
void dnotify_targets (DNotifier *target, dtag_t tag, dval_t val)
 Macro to notify all the targets of target object.

Detailed Description

Notifier obj (interface).

Author:
Bernie Innocenti <bernie@codewiz.org>
Francesco Sacchi <batt@develer.com>

Definition in file dnotifier.h.


Define Documentation

#define DCONNECT (   src,
  tgt,
  map,
  opt 
)
Value:
do { \
        static DFilter _filter_; /* Declare a filter */ \
        filter_init(&(_filter_), map, opt, src, tgt); /* Init it. */ \
    } while (0)

Macro that connect src notifier to tgt using map and passing opt for filtering option.

It declares a static filter to achieve connection and messages translation.

Note:
Due its static filter declaration, DCONNECT MUST NOT be used inside loops or in functions called multiple times. Failing to do so will lead to unpredictable connections between notifiers.

Definition at line 143 of file dnotifier.h.


Function Documentation

void filter_init ( DFilter f,
const DFilterMap map,
bool  masked,
DNotifier source,
DNotifier target 
)

Filter init.

Filter init.

If masked is true, all the fields value in map must be interpreted as a mask of bits.

Definition at line 143 of file dnotifier.c.

void filter_mask_update ( DFilter f,
dtag_t  tag,
dval_t  val 
)

Filter update function with masking capabilities.

Filter update function with masking capabilities.

If a match is found change them to the corresponding ones in the map. If map is NULL the filter is trasparent and all messages sent to filter will be forwarded to its target.

Definition at line 106 of file dnotifier.c.

void filter_update ( DFilter f,
dtag_t  tag,
dval_t  val 
)

Filter update function without masking capabilities.

Filter update function without masking capabilities.

If a match is found change them to the corresponding ones in the map. If map is NULL the filter is trasparent and all messages sent to filter will be forwarded to its target.

Definition at line 70 of file dnotifier.c.