comctl32/tooltips: Reset window subclass data when removing tools.
[wine.git] / dlls / dplayx / dplayx_queue.h
blobe704d9a7077b6f1495d53080c9fdd14e67535f2a
1 /* A queue definition based on sys/queue.h TAILQ definitions
3 * Copyright 2000 Peter Hunnisett
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 * NOTES
20 * o Linked list implementation for dplay/dplobby. Based off of the BSD
21 * version found in <sys/queue.h>
22 * o Port it to <wine/list.h> ?
26 #ifndef __WINE_DPLAYX_QUEUE_H
27 #define __WINE_DPLAYX_QUEUE_H
29 #include <stdarg.h>
31 #include "windef.h"
32 #include "winbase.h"
34 #define DPQ_INSERT(a,b,c) DPQ_INSERT_IN_TAIL(a,b,c)
37 * Tail queue definitions.
39 #define DPQ_HEAD(type) \
40 struct { \
41 struct type *lpQHFirst; /* first element */ \
42 struct type **lpQHLast; /* addr of last next element */ \
45 #define DPQ_ENTRY(type) \
46 struct { \
47 struct type *lpQNext; /* next element */ \
48 struct type **lpQPrev; /* address of previous next element */ \
52 * Tail queue functions.
54 #define DPQ_INIT(head) \
55 do{ \
56 (head).lpQHFirst = NULL; \
57 (head).lpQHLast = &(head).lpQHFirst; \
58 } while(0)
60 /* Front of the queue */
61 #define DPQ_FIRST( head ) ( (head).lpQHFirst )
63 /* Check if the queue has any elements */
64 #define DPQ_IS_EMPTY( head ) ( DPQ_FIRST(head) == NULL )
66 /* Next entry -- FIXME: Convert everything over to this macro ... */
67 #define DPQ_NEXT( elem ) (elem).lpQNext
69 #define DPQ_IS_ENDOFLIST( elem ) \
70 ( DPQ_NEXT(elem) == NULL )
72 /* Insert element at end of queue */
73 #define DPQ_INSERT_IN_TAIL(head, elm, field) \
74 do { \
75 (elm)->field.lpQNext = NULL; \
76 (elm)->field.lpQPrev = (head).lpQHLast; \
77 *(head).lpQHLast = (elm); \
78 (head).lpQHLast = &(elm)->field.lpQNext; \
79 } while(0)
81 /* Remove element from the queue */
82 #define DPQ_REMOVE(head, elm, field) \
83 do { \
84 if (((elm)->field.lpQNext) != NULL) \
85 (elm)->field.lpQNext->field.lpQPrev = \
86 (elm)->field.lpQPrev; \
87 else \
88 (head).lpQHLast = (elm)->field.lpQPrev; \
89 *(elm)->field.lpQPrev = (elm)->field.lpQNext; \
90 } while(0)
92 /* head - pointer to DPQ_HEAD struct
93 * elm - how to find the next element
94 * field - to be concatenated to rc to compare with fieldToCompare
95 * fieldToCompare - The value that we're comparing against
96 * fieldCompareOperator - The logical operator to compare field and
97 * fieldToCompare.
98 * rc - Variable to put the return code. Same type as (head).lpQHFirst
100 #define DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
101 do { \
102 (rc) = DPQ_FIRST(head); /* NULL head? */ \
104 while( rc ) \
106 /* What we're searching for? */ \
107 if( (rc)->field fieldCompareOperator (fieldToCompare) ) \
109 break; /* rc == correct element */ \
112 /* End of list check */ \
113 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
115 rc = NULL; \
116 break; \
119 } while(0)
121 /* head - pointer to DPQ_HEAD struct
122 * elm - how to find the next element
123 * field - to be concatenated to rc to compare with fieldToCompare
124 * fieldToCompare - The value that we're comparing against
125 * compare_cb - Callback to invoke to determine if comparison should continue.
126 * Callback must be defined with DPQ_DECL_COMPARECB.
127 * rc - Variable to put the return code. Same type as (head).lpQHFirst
129 #define DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
130 do { \
131 (rc) = DPQ_FIRST(head); /* NULL head? */ \
133 while( rc ) \
135 /* What we're searching for? */ \
136 if( compare_cb( &((rc)->field), &(fieldToCompare) ) ) \
138 break; /* no more */ \
141 /* End of list check */ \
142 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
144 rc = NULL; \
145 break; \
148 } while(0)
150 /* How to define the method to be passed to DPQ_DELETEQ */
151 #define DPQ_DECL_COMPARECB( name, type ) BOOL name( const type* elem1, const type* elem2 )
154 /* head - pointer to DPQ_HEAD struct
155 * elm - how to find the next element
156 * field - to be concatenated to rc to compare with fieldToEqual
157 * fieldToCompare - The value that we're comparing against
158 * fieldCompareOperator - The logical operator to compare field and
159 * fieldToCompare.
160 * rc - Variable to put the return code. Same type as (head).lpQHFirst
162 #define DPQ_REMOVE_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
163 do { \
164 DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc );\
166 /* Was the element found? */ \
167 if( rc ) \
169 DPQ_REMOVE( head, rc, elm ); \
171 } while(0)
173 /* head - pointer to DPQ_HEAD struct
174 * elm - how to find the next element
175 * field - to be concatenated to rc to compare with fieldToCompare
176 * fieldToCompare - The value that we're comparing against
177 * compare_cb - Callback to invoke to determine if comparison should continue.
178 * Callback must be defined with DPQ_DECL_COMPARECB.
179 * rc - Variable to put the return code. Same type as (head).lpQHFirst
181 #define DPQ_REMOVE_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
182 do { \
183 DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc );\
185 /* Was the element found? */ \
186 if( rc ) \
188 DPQ_REMOVE( head, rc, elm ); \
190 } while(0)
193 /* Delete the entire queue
194 * head - pointer to the head of the queue
195 * field - field to access the next elements of the queue
196 * type - type of the pointer to the element element
197 * df - a delete function to be called. Declared with DPQ_DECL_DELETECB.
199 #define DPQ_DELETEQ( head, field, type, df ) \
200 do \
202 while( !DPQ_IS_EMPTY(head) ) \
204 type holder = DPQ_FIRST(head); \
205 DPQ_REMOVE( head, holder, field ); \
206 df( holder ); \
208 } while(0)
210 /* How to define the method to be passed to DPQ_DELETEQ */
211 #define DPQ_DECL_DELETECB( name, type ) void name( type elem )
213 /* Prototype of a method which just performs a HeapFree on the elem */
214 DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID ) DECLSPEC_HIDDEN;
216 #endif /* __WINE_DPLAYX_QUEUE_H */