[146] | 1 | //#ifdef STATISTICS |
---|
[71] | 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 | |
---|
[88] | 16 | typedef enum {NONE, VARIABLE, CONSTANT, OPERATOR_UNARY, OPERATOR_BINARY} data_type_t; |
---|
[71] | 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 |
---|
[88] | 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; |
---|
[71] | 33 | |
---|
| 34 | /* private : Stat_binary_tree (data_type_t data_type, data_t data); */ |
---|
[88] | 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 ); |
---|
[71] | 40 | |
---|
[88] | 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 ); |
---|
[71] | 47 | |
---|
[88] | 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); |
---|
[71] | 54 | |
---|
[88] | 55 | public : bool valid (void); |
---|
[71] | 56 | |
---|
[88] | 57 | public : counter_t eval (void); |
---|
[71] | 58 | |
---|
[88] | 59 | private : counter_t val_tree (void); |
---|
| 60 | private : counter_t val_leaf (void); |
---|
| 61 | private : bool is_leaf (void); |
---|
[71] | 62 | |
---|
[88] | 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 | |
---|
[71] | 69 | // public : friend std::ostream& operator<< (std::ostream&, const morpheo::Stat_binary_tree &); |
---|
| 70 | }; |
---|
| 71 | }; |
---|
| 72 | }; |
---|
| 73 | #endif |
---|
[146] | 74 | //#endif |
---|