[71] | 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 {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 (counter_t cst); |
---|
| 36 | public : Stat_binary_tree (counter_t * var); |
---|
| 37 | public : Stat_binary_tree (operator_t op ); |
---|
| 38 | |
---|
| 39 | public : ~Stat_binary_tree (void); |
---|
| 40 | |
---|
| 41 | private : void insert_tree (Stat_binary_tree * tree); |
---|
| 42 | public : Stat_binary_tree * insert_tree (counter_t cst); |
---|
| 43 | public : Stat_binary_tree * insert_tree (counter_t * var); |
---|
| 44 | public : Stat_binary_tree * insert_tree (operator_t op ); |
---|
| 45 | |
---|
| 46 | public : Stat_binary_tree * goto_top_level (void); |
---|
| 47 | public : Stat_binary_tree * goto_next_root (void); |
---|
| 48 | |
---|
| 49 | public : bool valid (void); |
---|
| 50 | |
---|
| 51 | public : counter_t eval (void); |
---|
| 52 | |
---|
| 53 | private : counter_t val_tree (void); |
---|
| 54 | private : counter_t val_leaf (void); |
---|
| 55 | private : bool is_leaf (void); |
---|
| 56 | |
---|
| 57 | // public : friend std::ostream& operator<< (std::ostream&, const morpheo::Stat_binary_tree &); |
---|
| 58 | }; |
---|
| 59 | }; |
---|
| 60 | }; |
---|
| 61 | #endif |
---|
| 62 | #endif |
---|