diff options
Diffstat (limited to 'libcnary/include/node.h')
| -rw-r--r-- | libcnary/include/node.h | 59 |
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 | |||
| 15 | struct node_list_t; | ||
| 16 | |||
| 17 | // This class implements the abstract iterator class | ||
| 18 | typedef 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 | |||
| 40 | void node_destroy(struct node_t* node); | ||
| 41 | struct node_t* node_create(struct node_t* parent, void* data); | ||
| 42 | |||
| 43 | int node_attach(struct node_t* parent, struct node_t* child); | ||
| 44 | int node_detach(struct node_t* parent, struct node_t* child); | ||
| 45 | int node_insert(struct node_t* parent, unsigned int index, struct node_t* child); | ||
| 46 | |||
| 47 | unsigned int node_n_children(struct node_t* node); | ||
| 48 | node_t* node_nth_child(struct node_t* node, unsigned int n); | ||
| 49 | node_t* node_first_child(struct node_t* node); | ||
| 50 | node_t* node_prev_sibling(struct node_t* node); | ||
| 51 | node_t* node_next_sibling(struct node_t* node); | ||
| 52 | int node_child_position(struct node_t* parent, node_t* child); | ||
| 53 | |||
| 54 | typedef void* (*copy_func_t)(const void *src); | ||
| 55 | node_t* node_copy_deep(node_t* node, copy_func_t copy_func); | ||
| 56 | |||
| 57 | void node_debug(struct node_t* node); | ||
| 58 | |||
| 59 | #endif /* NODE_H_ */ | ||
