1 | #ifdef STATISTICS |
---|
2 | #ifndef morpheo_behavioural_Stat_binary_tree_h |
---|
3 | #define morpheo_behavioural_Stat_binary_tree_h |
---|
4 | |
---|
5 | #include "Behavioural/include/Stat_type.h" |
---|
6 | #include "Common/include/ErrorMorpheo.h" |
---|
7 | #include "Common/include/Message.h" |
---|
8 | #include <string> |
---|
9 | #include <map> |
---|
10 | #include <list> |
---|
11 | #include <iostream> |
---|
12 | |
---|
13 | namespace morpheo { |
---|
14 | namespace behavioural { |
---|
15 | |
---|
16 | typedef enum {NONE, VARIABLE, CONSTANT, OPERATOR_UNARY, OPERATOR_BINARY} data_type_t; |
---|
17 | |
---|
18 | typedef union |
---|
19 | { |
---|
20 | counter_t cst; |
---|
21 | counter_t * var; |
---|
22 | operator_t op; |
---|
23 | } data_t; |
---|
24 | |
---|
25 | class Stat_binary_tree |
---|
26 | { |
---|
27 | // arbre binaire |
---|
28 | private : Stat_binary_tree * _root; |
---|
29 | private : Stat_binary_tree * _left; |
---|
30 | private : Stat_binary_tree * _right; |
---|
31 | private : data_type_t _data_type; |
---|
32 | private : data_t _data; |
---|
33 | |
---|
34 | /* private : Stat_binary_tree (data_type_t data_type, data_t data); */ |
---|
35 | public : Stat_binary_tree (std::string expr, |
---|
36 | std::map<std::string, counter_t*> * operand); |
---|
37 | public : Stat_binary_tree (counter_t cst); |
---|
38 | public : Stat_binary_tree (counter_t * var); |
---|
39 | public : Stat_binary_tree (operator_t op ); |
---|
40 | |
---|
41 | public : ~Stat_binary_tree (void); |
---|
42 | |
---|
43 | private : void insert_tree (Stat_binary_tree * tree); |
---|
44 | public : Stat_binary_tree * insert_tree (counter_t cst); |
---|
45 | public : Stat_binary_tree * insert_tree (counter_t * var); |
---|
46 | public : Stat_binary_tree * insert_tree (operator_t op ); |
---|
47 | |
---|
48 | private : void change_type (counter_t cst); |
---|
49 | private : void change_type (counter_t * var); |
---|
50 | private : void change_type (operator_t op ); |
---|
51 | |
---|
52 | public : Stat_binary_tree * goto_top_level (void); |
---|
53 | public : Stat_binary_tree * goto_next_root (void); |
---|
54 | |
---|
55 | public : bool valid (void); |
---|
56 | |
---|
57 | public : counter_t eval (void); |
---|
58 | |
---|
59 | private : counter_t val_tree (void); |
---|
60 | private : counter_t val_leaf (void); |
---|
61 | private : bool is_leaf (void); |
---|
62 | |
---|
63 | public : void import (std::string expr, |
---|
64 | std::map<std::string, counter_t*> * operand); |
---|
65 | |
---|
66 | |
---|
67 | public : void print (uint32_t depth=0); |
---|
68 | |
---|
69 | // public : friend std::ostream& operator<< (std::ostream&, const morpheo::Stat_binary_tree &); |
---|
70 | }; |
---|
71 | }; |
---|
72 | }; |
---|
73 | #endif |
---|
74 | #endif |
---|