1 | #ifdef STATISTICS |
---|
2 | #ifndef morpheo_behavioural_Stat_h |
---|
3 | #define morpheo_behavioural_Stat_h |
---|
4 | |
---|
5 | #include "Behavioural/include/Parameters_Statistics.h" |
---|
6 | #include "Behavioural/include/Stat_type.h" |
---|
7 | #include "Behavioural/include/Stat_binary_tree.h" |
---|
8 | #include "Behavioural/include/XML.h" |
---|
9 | #include "Common/include/ErrorMorpheo.h" |
---|
10 | #include "Common/include/Message.h" |
---|
11 | |
---|
12 | #ifdef SYSTEMC |
---|
13 | #include "systemc.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <stdint.h> |
---|
17 | #include <string> |
---|
18 | #include <map> |
---|
19 | #include <list> |
---|
20 | #include <iostream> |
---|
21 | |
---|
22 | namespace morpheo { |
---|
23 | namespace behavioural { |
---|
24 | |
---|
25 | typedef double cycle_t; |
---|
26 | |
---|
27 | typedef struct |
---|
28 | { |
---|
29 | counter_type_t type; |
---|
30 | counter_t * counter; |
---|
31 | std::string name; |
---|
32 | std::string unit; |
---|
33 | std::string description; |
---|
34 | std::list<counter_t> save_counter; |
---|
35 | } var_t; |
---|
36 | |
---|
37 | typedef struct |
---|
38 | { |
---|
39 | bool each_cycle; |
---|
40 | counter_t * variable; |
---|
41 | Stat_binary_tree * expression; |
---|
42 | } expr_t; |
---|
43 | |
---|
44 | class Stat |
---|
45 | { |
---|
46 | const std::string _name_instance; |
---|
47 | const std::string _name_component; |
---|
48 | const cycle_t _nb_cycle_before_begin; |
---|
49 | const cycle_t _period; |
---|
50 | const bool _save_periodic; |
---|
51 | // Tableau des variables |
---|
52 | std::map<std::string, var_t> * _list_operand; |
---|
53 | // Liste chaîné des expressions |
---|
54 | std::list<expr_t> * _list_expr; |
---|
55 | |
---|
56 | counter_t * _cycle; |
---|
57 | |
---|
58 | public : Stat (std::string name_instance, |
---|
59 | std::string name_component, |
---|
60 | Parameters_Statistics * param); |
---|
61 | |
---|
62 | public : Stat (std::string name_instance, |
---|
63 | std::string name_component, |
---|
64 | cycle_t nb_cycle_before_begin=0, |
---|
65 | cycle_t period=0); |
---|
66 | public : ~Stat (void); |
---|
67 | |
---|
68 | public : counter_t * create_variable (std::string varname); |
---|
69 | public : counter_t * create_counter (std::string varname, |
---|
70 | std::string unit, |
---|
71 | std::string description); |
---|
72 | private : counter_t * alloc_operand (counter_type_t type, |
---|
73 | std::string varname, |
---|
74 | std::string unit, |
---|
75 | std::string description); |
---|
76 | public : void create_expr (std::string varname, |
---|
77 | std::string expr, |
---|
78 | bool each_cycle=true); |
---|
79 | |
---|
80 | private : Stat_binary_tree * string2tree (std::string expr); |
---|
81 | |
---|
82 | public : void end_cycle (void); |
---|
83 | private : void end_simulation (void); |
---|
84 | private : void test_and_save (bool force_save=false); |
---|
85 | private : void eval_exprs (bool only_each_cycle=true); |
---|
86 | private : void eval_expr (expr_t expr); |
---|
87 | |
---|
88 | private : bool is_valid_var (std::string expr); |
---|
89 | |
---|
90 | private : void generate_file (void); |
---|
91 | |
---|
92 | public : std::string print (uint32_t depth=0); |
---|
93 | }; |
---|
94 | |
---|
95 | }; |
---|
96 | }; |
---|
97 | #endif |
---|
98 | #endif |
---|