Mercurial > MadButterfly
diff include/mb_observer.h @ 1067:7b4e80ab671a openvg
merge from default branch
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 01 Dec 2010 12:25:56 +0800 |
parents | e415c55b4a0d |
children | 1993e5ae60aa |
line wrap: on
line diff
--- a/include/mb_observer.h Mon Jul 19 15:44:49 2010 +0800 +++ b/include/mb_observer.h Wed Dec 01 12:25:56 2010 +0800 @@ -1,3 +1,5 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 #ifndef __OBSERVER_H_ #define __OBSERVER_H_ @@ -8,7 +10,7 @@ typedef struct _subject subject_t; typedef struct _mouse_event mouse_event_t; typedef struct _monitor_event monitor_event_t; -typedef struct _ob_factory ob_factory_t; +typedef struct _observer_factory observer_factory_t; typedef void (*evt_handler)(event_t *event, void *arg); struct _event { @@ -53,7 +55,7 @@ int flags; subject_t *monitor_sub; /*!< \brief Monitor adding/removing * obervers on this subject. */ - ob_factory_t *factory; + observer_factory_t *factory; STAILQ(observer_t) observers; }; /*! \brief Flag that make a subject to stop propagate events to parents. */ @@ -85,13 +87,13 @@ * It provides functions for allocation of subject and observer objects, * and strategy function for getting the subject of parent coord object. */ -struct _ob_factory { - subject_t *(*subject_alloc)(ob_factory_t *factory); - void (*subject_free)(ob_factory_t *factory, subject_t *subject); - observer_t *(*observer_alloc)(ob_factory_t *factory); - void (*observer_free)(ob_factory_t *factory, observer_t *observer); +struct _observer_factory { + subject_t *(*subject_alloc)(observer_factory_t *factory); + void (*subject_free)(observer_factory_t *factory, subject_t *subject); + observer_t *(*observer_alloc)(observer_factory_t *factory); + void (*observer_free)(observer_factory_t *factory, observer_t *observer); /*! This is a strategy function to get subjects of parents. */ - subject_t *(*get_parent_subject)(ob_factory_t *factory, + subject_t *(*get_parent_subject)(observer_factory_t *factory, subject_t *cur_subject); }; @@ -103,7 +105,7 @@ EVT_MOUSE_MOVE_RAW }; -extern subject_t *subject_new(ob_factory_t *factory, +extern subject_t *subject_new(observer_factory_t *factory, void *obj, int obj_type); extern void subject_free(subject_t *subject); extern void subject_notify(subject_t *subject, event_t *evt);