Showing
5 changed files
with
84 additions
and
1 deletions
include/interface/observer.h
0 → 100644
1 | +#ifndef __OBSERVER_H__ | |
2 | +#define __OBSERVER_H__ | |
3 | + | |
4 | +typedef void (* fptr_observerNotify)(void *, void*); | |
5 | + | |
6 | +extern const struct interface i_Observer; | |
7 | + | |
8 | +struct i_Observer { | |
9 | + const struct interface * const _; | |
10 | + fptr_observerNotify notify; | |
11 | +}; | |
12 | + | |
13 | +extern void observerNotify(void *, void *); | |
14 | + | |
15 | +#endif // __OBSERVER_H__ | |
16 | + | |
17 | +// vim: set ts=4 sw=4: | ... | ... |
include/interface/subject.h
0 → 100644
1 | +#ifndef __SUBJECT_H__ | |
2 | +#define __SUBJECT_H__ | |
3 | + | |
4 | +typedef void (* fptr_subjectAttach)(void *, void *); | |
5 | +typedef void (* fptr_subjectDetach)(void *, void *); | |
6 | +typedef void (* fptr_subjectNotify)(void *); | |
7 | + | |
8 | +extern const struct interface i_Subject; | |
9 | + | |
10 | +struct i_Subject { | |
11 | + const struct interface * const _; | |
12 | + fptr_subjectAttach attach; | |
13 | + fptr_subjectDetach detach; | |
14 | + fptr_subjectNotify notify; | |
15 | +}; | |
16 | + | |
17 | +extern void subjectAttach(void *, void *); | |
18 | +extern void subjectDetach(void *, void *); | |
19 | +extern void subjectNotify(void *); | |
20 | + | |
21 | +#endif // __SUBJECT_H__ | |
22 | + | |
23 | +// vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -2,7 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 |
2 | 2 | AUTOMAKE_OPTIONS = subdir-objects |
3 | 3 | |
4 | 4 | IFACE = interface/class.c interface/stream_reader.c interface/logger.c \ |
5 | - interface/stream_writer.c interface/http_intro.c | |
5 | + interface/stream_writer.c interface/http_intro.c \ | |
6 | + interface/subject.c interface/observer.c | |
6 | 7 | CLASS = class.c interface.c |
7 | 8 | SOCKET = socket.c socket/accept.c socket/connect.c socket/listen.c |
8 | 9 | SERVER = server.c server/run.c server/close_conn.c | ... | ... |
src/interface/observer.c
0 → 100644
src/interface/subject.c
0 → 100644
1 | +#include "class.h" | |
2 | +#include "interface/subject.h" | |
3 | + | |
4 | +const struct interface i_Subject = { | |
5 | + "subject", | |
6 | + 3 | |
7 | +}; | |
8 | + | |
9 | +void | |
10 | +subjectAttach(void * subject, void * observer) | |
11 | +{ | |
12 | + CALL(subject, Subject, attach, observer); | |
13 | +} | |
14 | + | |
15 | +void | |
16 | +subjectDetach(void * subject, void * observer) | |
17 | +{ | |
18 | + CALL(subject, Subject, detach, observer); | |
19 | +} | |
20 | + | |
21 | +void | |
22 | +subjectNotify(void * subject) | |
23 | +{ | |
24 | + CALL(subject, Subject, notify); | |
25 | +} | |
26 | + | |
27 | +// vim: set ts=4 sw=4: | ... | ... |
Please
register
or
login
to post a comment