src/cx/collection.h

changeset 856
6bbbf219251d
parent 855
35bcb3216c0d
child 857
4d12e34bb130
equal deleted inserted replaced
855:35bcb3216c0d 856:6bbbf219251d
95 }; 95 };
96 96
97 /** 97 /**
98 * Use this macro to declare common members for a collection structure. 98 * Use this macro to declare common members for a collection structure.
99 */ 99 */
100 #define CX_COLLECTION_BASE struct cx_collection_s base 100 #define CX_COLLECTION_BASE struct cx_collection_s collection
101 101
102 /** 102 /**
103 * Invokes the simple destructor function for a specific element. 103 * Invokes the simple destructor function for a specific element.
104 * 104 *
105 * Usually only used by collection implementations. There should be no need 105 * Usually only used by collection implementations. There should be no need
107 * 107 *
108 * @param c the collection 108 * @param c the collection
109 * @param e the element 109 * @param e the element
110 */ 110 */
111 #define cx_invoke_simple_destructor(c, e) \ 111 #define cx_invoke_simple_destructor(c, e) \
112 (c)->base.simple_destructor((c)->base.store_pointer ? (*((void **) (e))) : (e)) 112 (c)->collection.simple_destructor((c)->collection.store_pointer ? (*((void **) (e))) : (e))
113 113
114 /** 114 /**
115 * Invokes the advanced destructor function for a specific element. 115 * Invokes the advanced destructor function for a specific element.
116 * 116 *
117 * Usually only used by collection implementations. There should be no need 117 * Usually only used by collection implementations. There should be no need
119 * 119 *
120 * @param c the collection 120 * @param c the collection
121 * @param e the element 121 * @param e the element
122 */ 122 */
123 #define cx_invoke_advanced_destructor(c, e) \ 123 #define cx_invoke_advanced_destructor(c, e) \
124 (c)->base.advanced_destructor((c)->base.destructor_data, \ 124 (c)->collection.advanced_destructor((c)->collection.destructor_data, \
125 (c)->base.store_pointer ? (*((void **) (e))) : (e)) 125 (c)->collection.store_pointer ? (*((void **) (e))) : (e))
126 126
127 127
128 /** 128 /**
129 * Invokes all available destructor functions for a specific element. 129 * Invokes all available destructor functions for a specific element.
130 * 130 *
133 * 133 *
134 * @param c the collection 134 * @param c the collection
135 * @param e the element 135 * @param e the element
136 */ 136 */
137 #define cx_invoke_destructor(c, e) \ 137 #define cx_invoke_destructor(c, e) \
138 if ((c)->base.simple_destructor) cx_invoke_simple_destructor(c,e); \ 138 if ((c)->collection.simple_destructor) cx_invoke_simple_destructor(c,e); \
139 if ((c)->base.advanced_destructor) cx_invoke_advanced_destructor(c,e) 139 if ((c)->collection.advanced_destructor) cx_invoke_advanced_destructor(c,e)
140 140
141 #ifdef __cplusplus 141 #ifdef __cplusplus
142 } // extern "C" 142 } // extern "C"
143 #endif 143 #endif
144 144

mercurial