BRL-CAD

libbu observer. More...

Collaboration diagram for Observer:

Files

file  observer.h
 

Data Structures

struct  bu_observer
 
struct  bu_observer_list
 

Macros

#define BU_OBSERVER_NULL   ((struct bu_observer *)0)
 
#define BU_CK_OBSERVER(_op)   BU_CKMAG(_op, BU_OBSERVER_MAGIC, "bu_observer magic")
 
#define BU_OBSERVER_INIT(_op)
 
#define BU_OBSERVER_INIT_ZERO   { BU_OBSERVER_MAGIC, BU_VLS_INIT_ZERO, BU_VLS_INIT_ZERO }
 
#define BU_OBSERVER_LIST_INIT_ZERO   { 0, 0, NULL }
 
#define BU_OBSERVER_IS_INITIALIZED(_op)   (((struct bu_observer *)(_op) != BU_OBSERVER_NULL) && LIKELY((_op)->magic == BU_OBSERVER_MAGIC))
 

Typedefs

typedef void() bu_observer_eval_t(void *, const char *)
 
typedef struct bu_observer bu_observer_t
 

Functions

int bu_observer_cmd (void *clientData, int argc, const char *argv[])
 Routines for implementing the observer pattern. More...
 
void bu_observer_notify (void *context, struct bu_observer_list *observers, char *self, bu_observer_eval_t *ofunc)
 
void bu_observer_free (struct bu_observer_list *)
 

Detailed Description

libbu observer.

Macro Definition Documentation

◆ BU_OBSERVER_NULL

#define BU_OBSERVER_NULL   ((struct bu_observer *)0)

Definition at line 51 of file observer.h.

◆ BU_CK_OBSERVER

#define BU_CK_OBSERVER (   _op)    BU_CKMAG(_op, BU_OBSERVER_MAGIC, "bu_observer magic")

asserts the integrity of a non-head node bu_observer struct.

Definition at line 61 of file observer.h.

◆ BU_OBSERVER_INIT

#define BU_OBSERVER_INIT (   _op)
Value:
{ \
(_op)->magic = BU_OBSERVER_MAGIC; \
BU_VLS_INIT(&(_op)->observer); \
BU_VLS_INIT(&(_op)->cmd); \
}
#define BU_OBSERVER_MAGIC
Definition: magic.h:67

initializes a bu_observer struct without allocating any memory.

Definition at line 66 of file observer.h.

◆ BU_OBSERVER_INIT_ZERO

#define BU_OBSERVER_INIT_ZERO   { BU_OBSERVER_MAGIC, BU_VLS_INIT_ZERO, BU_VLS_INIT_ZERO }

macro suitable for declaration statement initialization of a bu_observer struct. does not allocate memory. not suitable for a head node.

Definition at line 76 of file observer.h.

◆ BU_OBSERVER_LIST_INIT_ZERO

#define BU_OBSERVER_LIST_INIT_ZERO   { 0, 0, NULL }

Definition at line 78 of file observer.h.

◆ BU_OBSERVER_IS_INITIALIZED

#define BU_OBSERVER_IS_INITIALIZED (   _op)    (((struct bu_observer *)(_op) != BU_OBSERVER_NULL) && LIKELY((_op)->magic == BU_OBSERVER_MAGIC))

returns truthfully whether a bu_observer has been initialized.

Definition at line 83 of file observer.h.

Typedef Documentation

◆ bu_observer_eval_t

typedef void() bu_observer_eval_t(void *, const char *)

Definition at line 40 of file observer.h.

◆ bu_observer_t

typedef struct bu_observer bu_observer_t

Definition at line 50 of file observer.h.

Function Documentation

◆ bu_observer_cmd()

int bu_observer_cmd ( void *  clientData,
int  argc,
const char *  argv[] 
)

Routines for implementing the observer pattern.

runs a given command, calling the corresponding observer callback if it matches.

◆ bu_observer_notify()

void bu_observer_notify ( void *  context,
struct bu_observer_list observers,
char *  self,
bu_observer_eval_t ofunc 
)

Notify observers.

◆ bu_observer_free()

void bu_observer_free ( struct bu_observer_list )

Free observers.