summaryrefslogtreecommitdiffstats
path: root/libcnary/include/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcnary/include/node.h')
-rw-r--r--libcnary/include/node.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/libcnary/include/node.h b/libcnary/include/node.h
new file mode 100644
index 0000000..35f6333
--- /dev/null
+++ b/libcnary/include/node.h
@@ -0,0 +1,59 @@
1/*
2 * node.h
3 *
4 * Created on: Mar 7, 2011
5 * Author: posixninja
6 */
7
8#ifndef NODE_H_
9#define NODE_H_
10
11#include "object.h"
12
13#define NODE_TYPE 1;
14
15struct node_list_t;
16
17// This class implements the abstract iterator class
18typedef struct node_t {
19 // Super class
20 struct node_t* next;
21 struct node_t* prev;
22 unsigned int count;
23
24 // Local Properties
25 int isRoot;
26 int isLeaf;
27
28 // Local Members
29 void *data;
30 unsigned int depth;
31 struct node_t* parent;
32 struct node_list_t* children;
33
34 // Virtual Functions
35 int(*attach)(struct node_t* parent, struct node_t* child);
36 int(*detach)(struct node_t* parent, struct node_t* child);
37
38} node_t;
39
40void node_destroy(struct node_t* node);
41struct node_t* node_create(struct node_t* parent, void* data);
42
43int node_attach(struct node_t* parent, struct node_t* child);
44int node_detach(struct node_t* parent, struct node_t* child);
45int node_insert(struct node_t* parent, unsigned int index, struct node_t* child);
46
47unsigned int node_n_children(struct node_t* node);
48node_t* node_nth_child(struct node_t* node, unsigned int n);
49node_t* node_first_child(struct node_t* node);
50node_t* node_prev_sibling(struct node_t* node);
51node_t* node_next_sibling(struct node_t* node);
52int node_child_position(struct node_t* parent, node_t* child);
53
54typedef void* (*copy_func_t)(const void *src);
55node_t* node_copy_deep(node_t* node, copy_func_t copy_func);
56
57void node_debug(struct node_t* node);
58
59#endif /* NODE_H_ */