00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CU_HOOK_H
00019 #define CU_HOOK_H
00020
00021 #include <cu/fwd.h>
00022 #include <cu/inherit.h>
00023 #include <cu/dlink.h>
00024
00025 CU_BEGIN_DECLARATIONS
00026
00027
00028
00029
00030 typedef struct cu_hook_node *cu_hook_node_t;
00031 struct cu_hook_node
00032 {
00033 cu_inherit (cu_dlink);
00034 cu_clop0(f, void);
00035 };
00036
00037 #ifndef CU_IN_DOXYGEN
00038 void cuP_hook_init(cu_hook_node_t hook);
00039 void cuP_hook_prepend(cu_hook_node_t hook, cu_clop0(f, void));
00040 void cuP_hook_append(cu_hook_node_t hook, cu_clop0(f, void));
00041 #endif
00042
00043
00044
00045
00046
00047
00048 #define CU_HOOK_TEMPLATE(name, f_decl) \
00049 typedef struct name *name##_t; \
00050 struct name { cu_inherit (cu_hook_node); }; \
00051 \
00052 \
00053 CU_SINLINE void name##_init(name##_t hook) \
00054 { cuP_hook_init((cu_hook_node_t)hook); } \
00055 \
00056 \
00057 CU_SINLINE cu_bool_t name##_is_empty(name##_t hook) \
00058 { return cu_dlink_is_singleton(cu_to2(cu_dlink, cu_hook_node, hook)); }\
00059 \
00060 \
00061 CU_SINLINE void name##_prepend(name##_t hook, f_decl) \
00062 { cuP_hook_prepend((cu_hook_node_t)hook, (cu_clop0(, void))f); } \
00063 \
00064 \
00065 CU_SINLINE void name##_append(name##_t hook, f_decl) \
00066 { cuP_hook_append((cu_hook_node_t)hook, (cu_clop0(, void))f); }
00067
00068 #define CU_HOOK_NEXT(node) \
00069 cu_from(cu_hook_node, cu_dlink, cu_to(cu_dlink, node)->next)
00070
00071
00072
00073
00074 #define CU_HOOK_FOR(node, hook) \
00075 for (node = CU_HOOK_NEXT(cu_to(cu_hook_node, hook)); \
00076 node != cu_to(cu_hook_node, hook); \
00077 node = CU_HOOK_NEXT(node))
00078
00079 CU_HOOK_TEMPLATE(cu_iter_hook, cu_clop0(f, void))
00080
00081 void cu_iter_hook_call(cu_iter_hook_t hook);
00082
00083 CU_HOOK_TEMPLATE(cu_iterA_hook, cu_clop0(f, cu_bool_t))
00084
00085
00086 cu_bool_t cu_iterA_hook_call(cu_iterA_hook_t hook);
00087
00088 CU_HOOK_TEMPLATE(cu_iter_ptr_hook, cu_clop(f, void, void *))
00089
00090 void cu_iter_ptr_hook_call(cu_iter_ptr_hook_t hook, void *arg);
00091
00092 CU_HOOK_TEMPLATE(cu_iterA_ptr_hook, cu_clop(f, cu_bool_t, void *))
00093
00094
00095 cu_bool_t cu_iterA_ptr_hook_call(cu_iterA_ptr_hook_t hook, void *arg);
00096
00097 CU_HOOK_TEMPLATE(cu_ptr_compose_hook, cu_clop(f, void *, void *))
00098
00099
00100 void *cu_ptr_compose_hook_call(cu_ptr_compose_hook_t hook, void *arg);
00101
00102
00103 CU_END_DECLARATIONS
00104
00105 #endif