[71] | 1 | #ifdef STATISTICS |
---|
| 2 | #include "Behavioural/include/Stat.h" |
---|
| 3 | |
---|
| 4 | namespace morpheo { |
---|
| 5 | namespace behavioural { |
---|
| 6 | |
---|
[139] | 7 | Stat::Stat (std::string name_instance, |
---|
| 8 | std::string name_component, |
---|
[71] | 9 | Parameters_Statistics * param): |
---|
| 10 | _name_instance (name_instance), |
---|
| 11 | _name_component (name_component), |
---|
| 12 | _nb_cycle_before_begin (static_cast<cycle_t>(param->_nb_cycle_before_begin)), |
---|
| 13 | _period (static_cast<cycle_t>(param->_period_save)), |
---|
| 14 | _save_periodic (_period>0) |
---|
| 15 | { |
---|
[138] | 16 | _generate_file = true; |
---|
| 17 | |
---|
[139] | 18 | _list_operand = new std::map<std::string, var_t>; |
---|
| 19 | _list_expr_per_cycle = new std::list<expr_t>; |
---|
| 20 | _list_expr_per_period = new std::list<expr_t>; |
---|
| 21 | _list_stat = new std::list<Stat *>; |
---|
| 22 | _list_counters = new std::list<counters_t *>; |
---|
[71] | 23 | |
---|
[139] | 24 | _cycle = create_variable("cycle"); |
---|
| 25 | // _cycle = create_counter("cycle","",""); |
---|
| 26 | *_cycle = 0; // for the first period |
---|
[71] | 27 | } |
---|
| 28 | |
---|
| 29 | Stat::Stat (std::string name_instance, |
---|
| 30 | std::string name_component, |
---|
[139] | 31 | cycle_t nb_cycle_before_begin, |
---|
| 32 | cycle_t period): |
---|
[71] | 33 | _name_instance (name_instance), |
---|
| 34 | _name_component (name_component), |
---|
| 35 | _nb_cycle_before_begin (nb_cycle_before_begin), |
---|
| 36 | _period (period), |
---|
| 37 | _save_periodic (period>0) |
---|
| 38 | { |
---|
[138] | 39 | _generate_file = true; |
---|
| 40 | |
---|
[139] | 41 | _list_operand = new std::map<std::string, var_t>; |
---|
| 42 | _list_expr_per_cycle = new std::list<expr_t>; |
---|
| 43 | _list_expr_per_period = new std::list<expr_t>; |
---|
| 44 | _list_stat = new std::list<Stat *>; |
---|
| 45 | _list_counters = new std::list<counters_t *>; |
---|
[71] | 46 | |
---|
[139] | 47 | _cycle = create_variable("cycle"); |
---|
| 48 | // _cycle = create_counter("cycle","",""); |
---|
| 49 | *_cycle = 0; // for the first period |
---|
[71] | 50 | } |
---|
| 51 | |
---|
| 52 | Stat::~Stat (void) |
---|
| 53 | { |
---|
[74] | 54 | if (_generate_file) |
---|
| 55 | generate_file(); |
---|
[71] | 56 | |
---|
| 57 | // parcourir la liste et desallouer les counters |
---|
| 58 | for (std::map<std::string, var_t>::iterator i=_list_operand->begin(); |
---|
| 59 | i!= _list_operand->end(); |
---|
| 60 | ++i) |
---|
| 61 | { |
---|
| 62 | delete i->second.counter; |
---|
| 63 | } |
---|
| 64 | delete _list_operand; |
---|
| 65 | |
---|
| 66 | // parcourir la liste et desallouer les arbres |
---|
[139] | 67 | for (std::list<expr_t>::iterator i=_list_expr_per_cycle->begin(); |
---|
| 68 | i!= _list_expr_per_cycle->end(); |
---|
[71] | 69 | ++i) |
---|
| 70 | { |
---|
| 71 | delete i->expression; |
---|
| 72 | } |
---|
[139] | 73 | delete _list_expr_per_cycle; |
---|
[138] | 74 | |
---|
[139] | 75 | for (std::list<expr_t>::iterator i=_list_expr_per_period->begin(); |
---|
| 76 | i!= _list_expr_per_period->end(); |
---|
| 77 | ++i) |
---|
| 78 | { |
---|
| 79 | delete i->expression; |
---|
| 80 | } |
---|
| 81 | delete _list_expr_per_period; |
---|
| 82 | |
---|
[138] | 83 | // parcourir la liste et desallouer les arbres |
---|
| 84 | for (std::list<counters_t*>::iterator i=_list_counters->begin(); |
---|
| 85 | i!= _list_counters->end(); |
---|
| 86 | ++i) |
---|
| 87 | { |
---|
| 88 | delete *i; |
---|
| 89 | } |
---|
| 90 | delete _list_counters; |
---|
| 91 | |
---|
[74] | 92 | delete _list_stat; |
---|
[71] | 93 | } |
---|
| 94 | }; |
---|
| 95 | }; |
---|
| 96 | #endif |
---|