Coconut Framework  beta
CNNode.h
Go to the documentation of this file.
1 
8 #ifndef CNNODE_H
9 #define CNNODE_H
10 
11 #include "CNObject.h"
12 #include "CNObjectList.h"
13 
17 struct CNNode {
24 } ;
25 
27 typedef void (*CNPrintNodeFuncRef)(struct CNText * buf, const struct CNNode * src) ;
28 
30 struct CNNodeMethods {
35 } ;
36 
47 struct CNNode *
48 CNAllocateNode(struct CNGraph * parent, size_t size, const struct CNNodeMethods * methods) ;
49 
54 static inline void
55 CNRetainNode(struct CNNode * dst)
56 {
57  CNRetainObject(&(dst->superClass)) ;
58 }
59 
64 static inline void
65 CNReleaseNode(struct CNNode * dst)
66 {
67  CNReleaseObject(&(dst->superClass)) ;
68 }
69 
75 static inline struct CNResource *
76 CNResourceOfNode(struct CNNode * src)
77 {
78  return CNResourceOfObject(&(src->superClass)) ;
79 }
80 
86 static inline struct CNObject *
87 CNObjectOfNode(struct CNNode * src)
88 {
89  return &(src->superClass) ;
90 }
91 
98 static inline void
100 {
103 }
104 
110 static inline size_t
111 CNCountOfProducerEdges(const struct CNNode * src)
112 {
113  return CNCountOfObjectsInList(&(src->producerEdges)) ;
114 }
115 
121 static inline const struct CNListItem *
123 {
124  return CNFirstListObject(&(src->producerEdges)) ;
125 }
126 
132 static inline const struct CNListItem *
134 {
135  return CNCentinelListObject(&(src->producerEdges)) ;
136 }
137 
143 static inline size_t
144 CNCountOfConsumerEdges(const struct CNNode * src)
145 {
146  return CNCountOfObjectsInList(&(src->consumerEdges)) ;
147 }
148 
154 static inline const struct CNListItem *
156 {
157  return CNFirstListObject(&(src->consumerEdges)) ;
158 }
159 
165 static inline const struct CNListItem *
167 {
168  return CNCentinelListObject(&(src->consumerEdges)) ;
169 }
170 
176 static inline void
177 CNPrintNode(struct CNText * buf, const struct CNNode * src)
178 {
179  const struct CNNodeMethods * methods = (const struct CNNodeMethods *) CNMethodsOfObject(&(src->superClass)) ;
180  (*(methods->printNode))(buf, src) ;
181 }
182 
189 void
190 CNLinkNode(struct CNEdge * edge, struct CNNode * producer, struct CNNode * consumer) ;
191 
200 CNBoolean
201 CNUnlinkNode(struct CNGraph * graph, struct CNNode * producer, struct CNNode * consumer) ;
202 
210 CNBoolean
211 CNIsolateNode(struct CNGraph * graph, struct CNNode * dst) ;
212 
213 #endif /* CNNODE_H */
Single linked list item.
Definition: CNListItem.h:16
void(* CNPrintNodeFuncRef)(struct CNText *buf, const struct CNNode *src)
Definition: CNNode.h:27
static struct CNListItem * CNCentinelListObject(const struct CNObjectList *src)
Get centinel item of the list.
Definition: CNObjectList.h:83
static struct CNListItem * CNCentinelProducerEdgeInNode(const struct CNNode *src)
Get centinel producer node of the source node.
Definition: CNNode.h:133
static void CNReleaseNode(struct CNNode *dst)
Release the resource for the CNNode.
Definition: CNNode.h:65
static struct CNListItem * CNCentinelConsumerEdgeInNode(const struct CNNode *src)
Get centinel consumer node of the source node.
Definition: CNNode.h:166
Definition: CNText.h:20
Edge of the graph.
Definition: CNEdge.h:16
static size_t CNCountOfConsumerEdges(const struct CNNode *src)
Get number of consumers of the node.
Definition: CNNode.h:144
static size_t CNCountOfProducerEdges(const struct CNNode *src)
Get number of producers of the node.
Definition: CNNode.h:111
CNBoolean CNUnlinkNode(struct CNGraph *graph, struct CNNode *producer, struct CNNode *consumer)
Unlink 2 nodes.
static void CNDestroyContextOfNode(struct CNNode *dst)
Release the contex of the node.
Definition: CNNode.h:99
List of CNObject.
Definition: CNObjectList.h:17
Root object.
Definition: CNObject.h:38
CNPrintNodeFuncRef printNode
Definition: CNNode.h:34
static struct CNObject * CNObjectOfNode(struct CNNode *src)
Get object of the node.
Definition: CNNode.h:87
struct CNObject superClass
Definition: CNNode.h:19
static struct CNResource * CNResourceOfNode(struct CNNode *src)
Get resource of the CNNode.
Definition: CNNode.h:76
static struct CNListItem * CNFirstConsumerEdgeInNode(const struct CNNode *src)
Get first consumer node of the source node.
Definition: CNNode.h:155
void CNDestroyObjectList(struct CNObjectList *dst)
Destroy CNObject(s) in the list and list items.
Node of the direct acyclic graph.
Definition: CNNode.h:17
CNBoolean CNIsolateNode(struct CNGraph *graph, struct CNNode *dst)
Unlink all for the node.
Direct Acyclic Graph model.
Definition: CNGraph.h:17
Define CNObject data structure.
struct CNObjectList producerEdges
Definition: CNNode.h:21
struct CNObjectList consumerEdges
Definition: CNNode.h:23
Methods for CNNode.
Definition: CNNode.h:30
static void CNPrintNode(struct CNText *buf, const struct CNNode *src)
Print the context of node.
Definition: CNNode.h:177
Methods for CNObject.
Definition: CNObject.h:29
struct CNObjectMethods superClass
Definition: CNNode.h:32
void CNReleaseObject(struct CNObject *dst)
Release the object.
static void CNRetainObject(struct CNObject *dst)
Retain the object.
Definition: CNObject.h:75
struct CNNode * CNAllocateNode(struct CNGraph *parent, size_t size, const struct CNNodeMethods *methods)
Allocate CNNode.
static struct CNListItem * CNFirstProducerEdgeInNode(const struct CNNode *src)
Get first producer node of the source node.
Definition: CNNode.h:122
void CNLinkNode(struct CNEdge *edge, struct CNNode *producer, struct CNNode *consumer)
Link 2 nodes.
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
static struct CNResource * CNResourceOfObject(struct CNObject *src)
Get resource for the object.
Definition: CNObject.h:95
static size_t CNCountOfObjectsInList(const struct CNObjectList *src)
Get count of items in the object list.
Definition: CNObjectList.h:50
Define CNObjectList data structure.
static struct CNObjectMethods * CNMethodsOfObject(const struct CNObject *src)
Get methods for the object.
Definition: CNObject.h:106
static void CNRetainNode(struct CNNode *dst)
Retrain the resource for the CNNode.
Definition: CNNode.h:55
static struct CNListItem * CNFirstListObject(const struct CNObjectList *src)
Get 1st item in the list.
Definition: CNObjectList.h:61