1 
2 //metadoc CollectorMarker copyright Steve Dekorte 2002
3 //metadoc CollectorMarker license BSD revised
4 
5 #ifndef COLLECTORMARKER_DEFINED
6 #define COLLECTORMARKER_DEFINED 1
7 
8 #include "Common.h"
9 #include "List.h"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #if defined(WIN32)
16 #if defined(BUILDING_COLLECTOR_DLL) || defined(BUILDING_IOVMALL_DLL)
17 #define COLLECTOR_API __declspec(dllexport)
18 #else
19 #define COLLECTOR_API __declspec(dllimport)
20 #endif
21 
22 #else
23 #define COLLECTOR_API
24 #endif
25 
26 typedef void (CollectorDoFunc)(void *);
27 
28 typedef struct CollectorMarker CollectorMarker;
29 
30 #define CollectorMarkerSansPointer \
31 	CollectorMarker *prev; \
32 	CollectorMarker *next; \
33 	unsigned int color : 2; \
34 	unsigned int hash1; \
35 	unsigned int hash2;
36 
37 /*
38 #if !defined(COLLECTOROBJECTTYPE)
39 #define COLLECTOROBJECTTYPE void
40 #endif
41 */
42 
43 typedef struct IoObjectData IoObjectData;
44 #define IoObjectDataDefined 1
45 
46 struct CollectorMarker
47 {
48 	CollectorMarkerSansPointer
49 	IoObjectData *object;
50 };
51 
52 #define COLLECTOR_REF_TYPE(Type) \
53 typedef struct \
54 { \
55 	CollectorMarkerSansPointer; \
56 	Type *object; \
57 } Type ## Ref;
58 
59 #define CollectorMarker_setObject_(self, v) ((CollectorMarker *)self)->object = v;
60 #define CollectorMarker_object(self)       (((CollectorMarker *)self)->object)
61 
62 COLLECTOR_API CollectorMarker *CollectorMarker_new(void);
63 
64 CollectorMarker *CollectorMarker_newWithColor_(unsigned int color);
65 COLLECTOR_API void CollectorMarker_free(CollectorMarker *self);
66 
67 void CollectorMarker_loop(CollectorMarker *self);
68 void CollectorMarker_check(CollectorMarker *self);
69 
70 //void CollectorMarker_removeAndInsertAfter_(CollectorMarker *self, CollectorMarker *other);
71 void CollectorMarker_removeAndInsertBefore_(CollectorMarker *self, CollectorMarker *other);
72 //void CollectorMarker_removeIfNeededAndInsertAfter_(CollectorMarker *self, CollectorMarker *other);
73 
74 //void CollectorMarker_remove(CollectorMarker *self);
75 int CollectorMarker_count(CollectorMarker *self);
76 int CollectorMarker_colorSetIsEmpty(CollectorMarker *self);
77 
78 #define CollectorMarker_setColor_(self, c) ((CollectorMarker *)self)->color = c;
79 #define CollectorMarker_color(self)        ((CollectorMarker *)self)->color;
80 
81 #define CollectorMarker_num(self)         (((CollectorMarker *)self)->num);
82 #define CollectorMarker_setNext_(self, v) ((CollectorMarker *)self)->next = v;
83 #define CollectorMarker_setPrev_(self, v) ((CollectorMarker *)self)->prev = v;
84 
85 #define MARKER(v) ((CollectorMarker *)v)
86 
87 #define COLLECTMARKER_FOREACH(self, v, code) \
88 { \
89 	CollectorMarker *v = self->next; \
90 	CollectorMarker *_next; \
91 	unsigned int c = self->color; \
92 	\
93 	while (v->color == c) \
94 	{ \
95 		_next = v->next; \
96 		code; \
97 		v = _next;  \
98 	} \
99 }
100 
101 #include "CollectorMarker_inline.h"
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 #endif
107