New plugins system
[opsoft.git] / gclib2 / modules / Core / Tree.h
blobbb85a4764a18072601d82f303651e184f0d97a33
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 */
7 #ifndef DEFINE_TREE_H
8 #define DEFINE_TREE_H
10 struct node_t;
11 struct node_t
13 char * key;
14 char * userData;
15 uint32_t ID;
16 node_t * parentNode;
17 List * childNodes; // node_t *
20 typedef void (node_f) (node_t *);
22 /// Класс - дерево.
23 class Tree
25 public:
26 Tree ();
27 ~Tree ();
29 node_t * rootNode;
30 char * userData;
32 node_t * newNode (node_t * parent, char * key = NULL, char * userData = NULL);
33 char * freeNode (node_t * node, Dfunc_t f);
34 List * childs (node_t * node);
35 node_t * searchDown (node_t * node, char *key, uint32_t ID = 0);
36 node_t * searchUp (node_t * node, char *key, uint32_t ID = 0);
37 List * keyChilds (node_t * node, char * key, uint32_t ID = 0);
38 void foreach (node_f fn, node_t * m_node = NULL);
40 private:
41 uint16_t lastID;
44 #endif