1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : aw_nawar.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef AW_NAWAR_HXX |
---|
12 | #define AW_NAWAR_HXX |
---|
13 | |
---|
14 | #ifndef CB_H |
---|
15 | #include <cb.h> |
---|
16 | #endif |
---|
17 | #ifndef _GLIBCXX_CSTDDEF |
---|
18 | #include <cstddef> |
---|
19 | #endif |
---|
20 | #ifndef ARBTOOLS_H |
---|
21 | #include <arbtools.h> |
---|
22 | #endif |
---|
23 | #ifndef ARB_MSG_H |
---|
24 | #include <arb_msg.h> |
---|
25 | #endif |
---|
26 | |
---|
27 | class AW_root_cblist : virtual Noncopyable { |
---|
28 | RootCallback callback; |
---|
29 | AW_root_cblist *next; |
---|
30 | |
---|
31 | AW_root_cblist(AW_root_cblist *next_, const RootCallback& cb) : callback(cb), next(next_) {} |
---|
32 | ~AW_root_cblist() { delete next; } |
---|
33 | |
---|
34 | AW_root_cblist *unlink(const RootCallback& cb, AW_root_cblist*& found) { |
---|
35 | if (callback == cb) { |
---|
36 | AW_root_cblist *rest = next; |
---|
37 | |
---|
38 | found = this; |
---|
39 | next = NULp; |
---|
40 | |
---|
41 | return rest; |
---|
42 | } |
---|
43 | |
---|
44 | if (next) next = next->unlink(cb, found); |
---|
45 | return this; |
---|
46 | } |
---|
47 | |
---|
48 | void call(AW_root *root) { // runs the whole list in FIFO order |
---|
49 | if (next) next->call(root); |
---|
50 | |
---|
51 | arb_assert(!GB_have_error()); |
---|
52 | callback(root); |
---|
53 | arb_assert(!GB_have_error()); |
---|
54 | } |
---|
55 | |
---|
56 | public: |
---|
57 | |
---|
58 | static void add(AW_root_cblist*& listhead, const RootCallback& cb) { |
---|
59 | remove(listhead, cb); // first remove duplicated callbacks |
---|
60 | listhead = new AW_root_cblist(listhead, cb); |
---|
61 | } |
---|
62 | static void remove(AW_root_cblist*& listhead, const RootCallback& cb) { |
---|
63 | AW_root_cblist *found = NULp; |
---|
64 | if (listhead) listhead = listhead->unlink(cb, found); |
---|
65 | delete found; |
---|
66 | } |
---|
67 | static void clear(AW_root_cblist*& listhead) { |
---|
68 | if (listhead) { |
---|
69 | delete listhead; |
---|
70 | listhead = NULp; |
---|
71 | } |
---|
72 | } |
---|
73 | static void call(AW_root_cblist*& listhead, AW_root *root) { |
---|
74 | if (listhead) listhead->call(root); |
---|
75 | } |
---|
76 | |
---|
77 | bool contains(const RootCallback& cb) const { |
---|
78 | return (cb == callback) || (next && next->contains(cb)); |
---|
79 | } |
---|
80 | static bool contains(const AW_root_cblist*& listhead, const RootCallback& cb) { |
---|
81 | return listhead && listhead->contains(cb); |
---|
82 | } |
---|
83 | }; |
---|
84 | |
---|
85 | struct AW_var_target { |
---|
86 | AW_var_target(void *pntr, AW_var_target *next); |
---|
87 | |
---|
88 | void *pointer; |
---|
89 | AW_var_target *next; |
---|
90 | }; |
---|
91 | |
---|
92 | void aw_update_all_window_geometry_awars(AW_root *awr); |
---|
93 | void AW_forget_all_window_geometry(AW_window *aww); |
---|
94 | |
---|
95 | #else |
---|
96 | #error aw_nawar.hxx included twice |
---|
97 | #endif // AW_NAWAR_HXX |
---|
98 | |
---|