Coconut Framework  beta
CNObjectList.h
Go to the documentation of this file.
1 
8 #ifndef CNOBJECTLIST_H
9 #define CNOBJECTLIST_H
10 
11 #include "CNList.h"
12 #include "CNObject.h"
13 
18 {
20  struct CNList objectList ;
21 } ;
22 
28 static inline struct CNObjectList
29 CNMakeEmptyObjectList(struct CNResource * resource)
30 {
31  struct CNObjectList list = {
32  .objectList = CNMakeEmptyList(resource)
33  } ;
34  return list ;
35 }
36 
41 void
42 CNDestroyObjectList(struct CNObjectList * dst) ;
43 
49 static inline size_t
51 {
52  return CNCountOfItemsInList(&(src->objectList)) ;
53 }
54 
60 static inline struct CNListItem *
61 CNFirstListObject(const struct CNObjectList * src)
62 {
63  return CNFirstListItem(&(src->objectList)) ;
64 }
65 
71 static inline struct CNListItem *
72 CNLastListObject(const struct CNObjectList * src)
73 {
74  return CNLastListItem(&(src->objectList)) ;
75 }
76 
82 static inline struct CNListItem *
84 {
85  return CNCentinelListItem(&(src->objectList)) ;
86 }
87 
93 static inline void
94 CNAppendObjectToList(struct CNObjectList * dst, struct CNObject * src)
95 {
96  CNRetainObject(src) ;
97  CNAppendItemToList(&(dst->objectList), src) ;
98 }
99 
105 static inline void
106 CNPrependObjectToList(struct CNObjectList * dst, struct CNObject * src)
107 {
108  CNRetainObject(src) ;
109  CNPrependItemToList(&(dst->objectList), src) ;
110 }
111 
117 struct CNObjectList
118 CNCopyObjectList(const struct CNObjectList * src) ;
119 
127 static inline void
128 CNInsertObjectToList(struct CNObjectList * dst, struct CNListItem * prev, struct CNObject * src)
129 {
130  CNRetainObject(src) ;
131  CNInsertItemToList(&(dst->objectList), prev, src) ;
132 }
133 
141 void
142 CNInsertObjectsToList(struct CNObjectList * owner, struct CNListItem * prev, const struct CNObjectList * src) ;
143 
150 static inline struct CNObject *
151 CNUnlinkObjectFromList(struct CNObjectList * owner, struct CNListItem * dst)
152 {
153  return (struct CNObject *) CNUnlinkItemFromList(&(owner->objectList), dst) ;
154 }
155 
163 static inline struct CNObject *
165 {
166  return (struct CNObject *) CNUnlinkFirstItemFromList(&(dst->objectList)) ;
167 }
168 
176 static inline struct CNObject *
178 {
179  return (struct CNObject *) CNUnlinkLastItemFromList(&(dst->objectList)) ;
180 }
181 
187 static inline void
188 CNMoveObjectList(struct CNObjectList * dst, struct CNObjectList * src)
189 {
190  CNMoveList(&(dst->objectList), &(src->objectList)) ;
191 }
192 
198 void
199 CNAppendObjectsToList(struct CNObjectList * dst, struct CNObjectList * src) ;
200 
208 static inline struct CNListItem *
209 CNSearchObjectInList(const struct CNObjectList * list, struct CNObject * obj)
210 {
211  return CNSearchDataInList(&(list->objectList), obj) ;
212 }
213 
222 static inline struct CNListItem *
223 CNSearchMatchedObjectInList(const struct CNObjectList * list, CNMatchDataFuncRef func, void * info)
224 {
225  return CNSearchMatchedDataInList(&(list->objectList), func, info) ;
226 }
227 
235 CNBoolean
236 CNDeleteObjectInList(struct CNObjectList * dst, struct CNObject * obj) ;
237 
238 #endif /* CNOBJECTLIST_H */
Single linked list item.
Definition: CNListItem.h:16
struct CNListItem * CNSearchDataInList(const struct CNList *list, void *data)
Search list item which has source data reference.
static struct CNListItem * CNLastListObject(const struct CNObjectList *src)
Get last item in the list.
Definition: CNObjectList.h:72
static struct CNListItem * CNCentinelListObject(const struct CNObjectList *src)
Get centinel item of the list.
Definition: CNObjectList.h:83
void * CNUnlinkLastItemFromList(struct CNList *dst)
Get and unlink last item in the list.
static struct CNList CNMakeEmptyList(struct CNResource *resource)
Initialize CNList.
Definition: CNList.h:32
static struct CNObject * CNUnlinkObjectFromList(struct CNObjectList *owner, struct CNListItem *dst)
Unlink an item from the list and return it's data.
Definition: CNObjectList.h:151
static void CNPrependObjectToList(struct CNObjectList *dst, struct CNObject *src)
Prepend object to the list.
Definition: CNObjectList.h:106
List of pointers.
Definition: CNList.h:17
static struct CNListItem * CNCentinelListItem(const struct CNList *src)
Get centinel item of the list.
Definition: CNList.h:88
static struct CNObject * CNUnlinkFirstObjectFromList(struct CNObjectList *dst)
Get 1st object in the list.
Definition: CNObjectList.h:164
struct CNObjectList CNCopyObjectList(const struct CNObjectList *src)
Make the copy of source object list.
static void CNInsertObjectToList(struct CNObjectList *dst, struct CNListItem *prev, struct CNObject *src)
Insert item to the list.
Definition: CNObjectList.h:128
void * CNUnlinkItemFromList(struct CNList *owner, struct CNListItem *dst)
Unlink an item from the list and return it's data.
Define CNList data structure.
static struct CNObjectList CNMakeEmptyObjectList(struct CNResource *resource)
Initialize CNObjectList.
Definition: CNObjectList.h:29
void * CNUnlinkFirstItemFromList(struct CNList *dst)
Get and unlink 1st item in the list.
List of CNObject.
Definition: CNObjectList.h:17
void CNAppendItemToList(struct CNList *dst, void *src)
Append object to the list.
Root object.
Definition: CNObject.h:38
static struct CNListItem * CNLastListItem(const struct CNList *src)
Get last item in the list.
Definition: CNList.h:77
void CNMoveList(struct CNList *dst, struct CNList *src)
Move items from source to destination.
static struct CNObject * CNUnlinkLastObjectFromList(struct CNObjectList *dst)
Get last object in the list.
Definition: CNObjectList.h:177
void CNAppendObjectsToList(struct CNObjectList *dst, struct CNObjectList *src)
Copy objects from source to destination.
void CNInsertItemToList(struct CNList *owner, struct CNListItem *prev, void *src)
Insert item to the list.
struct CNListItem * CNSearchMatchedDataInList(const struct CNList *list, CNMatchDataFuncRef func, void *info)
Search list item which matched source data.
void CNDestroyObjectList(struct CNObjectList *dst)
Destroy CNObject(s) in the list and list items.
void CNInsertObjectsToList(struct CNObjectList *owner, struct CNListItem *prev, const struct CNObjectList *src)
Insert objects to the list.
void CNPrependItemToList(struct CNList *dst, void *src)
Prepend object to the list.
static void CNMoveObjectList(struct CNObjectList *dst, struct CNObjectList *src)
Move objects from source to destination.
Definition: CNObjectList.h:188
Define CNObject data structure.
struct CNList objectList
Definition: CNObjectList.h:20
static void CNAppendObjectToList(struct CNObjectList *dst, struct CNObject *src)
Append object to the list.
Definition: CNObjectList.h:94
CNBoolean(* CNMatchDataFuncRef)(const void *src, void *info)
Function to maching objects.
Definition: CNType.h:25
static void CNRetainObject(struct CNObject *dst)
Retain the object.
Definition: CNObject.h:75
static size_t CNCountOfItemsInList(const struct CNList *src)
Get count of items in the list.
Definition: CNList.h:55
static struct CNListItem * CNSearchObjectInList(const struct CNObjectList *list, struct CNObject *obj)
Search list item which has source data reference.
Definition: CNObjectList.h:209
CNBoolean CNDeleteObjectInList(struct CNObjectList *dst, struct CNObject *obj)
Delete object in the list.
static struct CNListItem * CNFirstListItem(const struct CNList *src)
Get 1st item in the list.
Definition: CNList.h:66
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
static size_t CNCountOfObjectsInList(const struct CNObjectList *src)
Get count of items in the object list.
Definition: CNObjectList.h:50
static struct CNListItem * CNSearchMatchedObjectInList(const struct CNObjectList *list, CNMatchDataFuncRef func, void *info)
Search object which matched source data.
Definition: CNObjectList.h:223
static struct CNListItem * CNFirstListObject(const struct CNObjectList *src)
Get 1st item in the list.
Definition: CNObjectList.h:61