Coconut Framework  beta
CNGraph.h
Go to the documentation of this file.
1 
8 #ifndef CNGRAPH_H
9 #define CNGRAPH_H
10 
11 #include "CNObject.h"
12 #include "CNObjectList.h"
13 
17 struct CNGraph {
24 } ;
25 
27 struct CNNodeMethods ;
28 
34 struct CNGraph *
35 CNAllocateGraph(struct CNResource * resource) ;
36 
41 static inline void
42 CNRetainGraph(struct CNGraph * dst)
43 {
44  CNRetainObject(&(dst->superClass)) ;
45 }
46 
51 static inline void
52 CNReleaseGraph(struct CNGraph * dst)
53 {
54  CNReleaseObject(&(dst->superClass)) ;
55 }
56 
62 static inline struct CNResource *
64 {
65  return CNResourceOfObject(&(src->superClass)) ;
66 }
67 
76 void
77 CNAppendNodeToGraph(struct CNGraph * dst, struct CNNode * src) ;
78 
87 void
88 CNAppendEdgeToGraph(struct CNGraph * dst, struct CNEdge * src) ;
89 
98 CNRemoveEdgeFromGraph(struct CNGraph * dst, struct CNEdge * src) ;
99 
105 static inline size_t
106 CNCountOfNodesInGraph(const struct CNGraph * src)
107 {
108  return CNCountOfObjectsInList(&(src->allNodes)) ;
109 }
110 
116 static inline const struct CNListItem *
117 CNFirstNodeInGraph(const struct CNGraph * src)
118 {
119  return CNFirstListObject(&(src->allNodes)) ;
120 }
121 
127 static inline const struct CNListItem *
128 CNCentinelNodeInGraph(const struct CNGraph * src)
129 {
130  return CNCentinelListObject(&(src->allNodes)) ;
131 }
132 
138 static inline const struct CNListItem *
139 CNFirstEdgeInGraph(const struct CNGraph * src)
140 {
141  return CNFirstListObject(&(src->allEdges)) ;
142 }
143 
149 static inline const struct CNListItem *
150 CNCentinelEdgeInGraph(const struct CNGraph * src)
151 {
152  return CNCentinelListObject(&(src->allEdges)) ;
153 }
154 
160 void
161 CNPrintGraph(struct CNText * buf, const struct CNGraph * src) ;
162 
163 #endif /* CNGRAPH_H */
164 
void CNAppendEdgeToGraph(struct CNGraph *dst, struct CNEdge *src)
Append edge to the graph.
struct CNObjectList allNodes
Definition: CNGraph.h:21
Single linked list item.
Definition: CNListItem.h:16
static struct CNListItem * CNCentinelListObject(const struct CNObjectList *src)
Get centinel item of the list.
Definition: CNObjectList.h:83
static void CNRetainGraph(struct CNGraph *dst)
Retrain the resource for the CNGraph.
Definition: CNGraph.h:42
Definition: CNText.h:20
Edge of the graph.
Definition: CNEdge.h:16
struct CNObjectList allEdges
Definition: CNGraph.h:23
List of CNObject.
Definition: CNObjectList.h:17
Root object.
Definition: CNObject.h:38
CNBoolean CNRemoveEdgeFromGraph(struct CNGraph *dst, struct CNEdge *src)
Remove edge from the graph.
struct CNGraph * CNAllocateGraph(struct CNResource *resource)
Allocate CNGraph.
void CNAppendNodeToGraph(struct CNGraph *dst, struct CNNode *src)
Append node to the graph.
Node of the direct acyclic graph.
Definition: CNNode.h:17
Direct Acyclic Graph model.
Definition: CNGraph.h:17
static size_t CNCountOfNodesInGraph(const struct CNGraph *src)
Count of nodes in the list.
Definition: CNGraph.h:106
Define CNObject data structure.
static void CNReleaseGraph(struct CNGraph *dst)
Release the resource for the CNGraph.
Definition: CNGraph.h:52
static struct CNListItem * CNCentinelNodeInGraph(const struct CNGraph *src)
Get centinel node in the graph.
Definition: CNGraph.h:128
Methods for CNNode.
Definition: CNNode.h:30
void CNReleaseObject(struct CNObject *dst)
Release the object.
static struct CNListItem * CNCentinelEdgeInGraph(const struct CNGraph *src)
Get centinel edge in the graph.
Definition: CNGraph.h:150
static void CNRetainObject(struct CNObject *dst)
Retain the object.
Definition: CNObject.h:75
static struct CNResource * CNResourceOfGraph(struct CNGraph *src)
Get resource of the graph.
Definition: CNGraph.h:63
static struct CNListItem * CNFirstEdgeInGraph(const struct CNGraph *src)
Get first edge in the graph.
Definition: CNGraph.h:139
void CNPrintGraph(struct CNText *buf, const struct CNGraph *src)
Print the context of graph.
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
struct CNObject superClass
Definition: CNGraph.h:19
Define CNObjectList data structure.
static struct CNListItem * CNFirstNodeInGraph(const struct CNGraph *src)
Get first node in the graph.
Definition: CNGraph.h:117
static struct CNListItem * CNFirstListObject(const struct CNObjectList *src)
Get 1st item in the list.
Definition: CNObjectList.h:61