[71] | 1 | #ifdef STATISTICS |
---|
| 2 | #include "Behavioural/include/Stat.h" |
---|
| 3 | |
---|
| 4 | namespace morpheo { |
---|
| 5 | namespace behavioural { |
---|
| 6 | |
---|
| 7 | Stat::Stat (std::string name_instance, |
---|
| 8 | std::string name_component, |
---|
| 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 | { |
---|
| 16 | _list_operand = new std::map<std::string, var_t>; |
---|
| 17 | _list_expr = new std::list<expr_t>; |
---|
[74] | 18 | _list_stat = new std::list<Stat *>; |
---|
[71] | 19 | |
---|
| 20 | _cycle = create_variable("cycle"); |
---|
| 21 | *_cycle = 0; // for the first period |
---|
[74] | 22 | |
---|
| 23 | _generate_file = true; |
---|
[71] | 24 | } |
---|
| 25 | |
---|
| 26 | Stat::Stat (std::string name_instance, |
---|
| 27 | std::string name_component, |
---|
| 28 | cycle_t nb_cycle_before_begin, |
---|
| 29 | cycle_t period): |
---|
| 30 | _name_instance (name_instance), |
---|
| 31 | _name_component (name_component), |
---|
| 32 | _nb_cycle_before_begin (nb_cycle_before_begin), |
---|
| 33 | _period (period), |
---|
| 34 | _save_periodic (period>0) |
---|
| 35 | { |
---|
| 36 | _list_operand = new std::map<std::string, var_t>; |
---|
| 37 | _list_expr = new std::list<expr_t>; |
---|
[74] | 38 | _list_stat = new std::list<Stat *>; |
---|
[71] | 39 | |
---|
| 40 | _cycle = create_variable("cycle"); |
---|
| 41 | *_cycle = 0; // for the first period |
---|
[74] | 42 | |
---|
| 43 | _generate_file = true; |
---|
[71] | 44 | } |
---|
| 45 | |
---|
| 46 | Stat::~Stat (void) |
---|
| 47 | { |
---|
[74] | 48 | if (_generate_file) |
---|
| 49 | generate_file(); |
---|
[71] | 50 | |
---|
| 51 | // parcourir la liste et desallouer les counters |
---|
| 52 | for (std::map<std::string, var_t>::iterator i=_list_operand->begin(); |
---|
| 53 | i!= _list_operand->end(); |
---|
| 54 | ++i) |
---|
| 55 | { |
---|
| 56 | delete i->second.counter; |
---|
| 57 | } |
---|
| 58 | delete _list_operand; |
---|
| 59 | |
---|
| 60 | // parcourir la liste et desallouer les arbres |
---|
| 61 | for (std::list<expr_t>::iterator i=_list_expr->begin(); |
---|
| 62 | i!= _list_expr->end(); |
---|
| 63 | ++i) |
---|
| 64 | { |
---|
| 65 | delete i->expression; |
---|
| 66 | } |
---|
| 67 | delete _list_expr; |
---|
[74] | 68 | delete _list_stat; |
---|
[71] | 69 | } |
---|
| 70 | }; |
---|
| 71 | }; |
---|
| 72 | #endif |
---|