Coconut Framework  beta
CNObjectArray.h
Go to the documentation of this file.
1 
8 #ifndef CNOBJECTARRAY_H
9 #define CNOBJECTARRAY_H
10 
11 #include "CNArray.h"
12 #include "CNObject.h"
13 
18 {
20  struct CNArray coreArray ;
21 } ;
22 
28 static inline void
29 CNInitObjectArray(struct CNObjectArray * dst, struct CNResource * resource)
30 {
31  CNInitArray(&(dst->coreArray), resource) ;
32 }
33 
38 void
39 CNDestroyObjectArray(struct CNObjectArray * dst) ;
40 
46 static inline struct CNResource *
48 {
49  return CNResourceOfArray(&(src->coreArray)) ;
50 }
51 
57 static inline uint64_t
59 {
60  return CNCountOfArray(&(src->coreArray)) ;
61 }
62 
71 static inline void
72 CNSetObjectToArray(struct CNObjectArray * dst, uint64_t index, struct CNObject * src)
73 {
74  CNRetainObject(src) ;
75  struct CNObject * orgobj = CNSetPointerToArray(&(dst->coreArray), index, src) ;
76  if(orgobj != NULL){
77  CNReleaseObject(src) ;
78  }
79 }
80 
86 static inline void
87 CNAddObjectToArray(struct CNObjectArray * dst, struct CNObject * src)
88 {
89  CNRetainObject(src) ;
90  struct CNObject * orgobj = CNSetPointerToArray(&(dst->coreArray), CNCountOfObjectArray(dst), src) ;
91  assert(orgobj == NULL) ;
92 }
93 
101 static inline struct CNObject *
102 CNObjectInArray(const struct CNObjectArray * src, uint64_t index)
103 {
104  return (struct CNObject *) CNPointerInArray(&(src->coreArray), index) ;
105 }
106 
113 struct CNObjectList
114 CNElementListOfObjectArray(const struct CNObjectArray * src, struct CNResource * resource) ;
115 
124 static inline CNBoolean
125 CNVisitElementOfObjectArray(const struct CNObjectArray * src, CNVisitElementOfArrayFuncRef visitfunc, void * info)
126 {
127  return CNVisitElementOfArray(&(src->coreArray), visitfunc, info) ;
128 }
129 
130 #endif /* CNOBJECTARRAY_H */
131 
static struct CNResource * CNResourceOfObjectArray(struct CNObjectArray *src)
Get resource of object array.
Definition: CNObjectArray.h:47
struct CNObjectList CNElementListOfObjectArray(const struct CNObjectArray *src, struct CNResource *resource)
Make object list of array.
Array of pointers.
Definition: CNArray.h:18
void * CNPointerInArray(const struct CNArray *src, uint64_t index)
Get element in the array.
Array of instances.
Definition: CNObjectArray.h:17
Define CNArray data structure.
void * CNSetPointerToArray(struct CNArray *dst, uint64_t index, void *src)
Set pointer to the array at the given index.
static uint64_t CNCountOfArray(const struct CNArray *src)
Get the count of elements in the array.
Definition: CNArray.h:64
List of CNObject.
Definition: CNObjectList.h:17
Root object.
Definition: CNObject.h:38
CNBoolean CNVisitElementOfArray(const struct CNArray *src, CNVisitElementOfArrayFuncRef visitfunc, void *info)
Visit all elements in the array.
static struct CNResource * CNResourceOfArray(const struct CNArray *src)
Get resource of array.
Definition: CNArray.h:53
static CNBoolean CNVisitElementOfObjectArray(const struct CNObjectArray *src, CNVisitElementOfArrayFuncRef visitfunc, void *info)
Visit all elements in the array.
Definition: CNObjectArray.h:125
void CNInitArray(struct CNArray *dst, struct CNResource *resource)
Initialize array.
CNBoolean(* CNVisitElementOfArrayFuncRef)(uint64_t index, void *src, void *info)
Definition: CNArray.h:30
static void CNSetObjectToArray(struct CNObjectArray *dst, uint64_t index, struct CNObject *src)
Set objectto the array at the given index.
Definition: CNObjectArray.h:72
static void CNInitObjectArray(struct CNObjectArray *dst, struct CNResource *resource)
Initialize instance array.
Definition: CNObjectArray.h:29
Define CNObject data structure.
struct CNResource * resource
Definition: CNArray.h:20
void CNDestroyObjectArray(struct CNObjectArray *dst)
Destroy instance array.
static void CNAddObjectToArray(struct CNObjectArray *dst, struct CNObject *src)
Add object as the last element of the array.
Definition: CNObjectArray.h:87
static uint64_t CNCountOfObjectArray(const struct CNObjectArray *src)
Get the count of elements in the array.
Definition: CNObjectArray.h:58
void CNReleaseObject(struct CNObject *dst)
Release the object.
static void CNRetainObject(struct CNObject *dst)
Retain the object.
Definition: CNObject.h:75
static struct CNObject * CNObjectInArray(const struct CNObjectArray *src, uint64_t index)
Get object in the array.
Definition: CNObjectArray.h:102
struct CNArray coreArray
Definition: CNObjectArray.h:20
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14