[71] | 1 | #ifndef morpheo_behavioural_Stat_type_h |
---|
| 2 | #define morpheo_behavioural_Stat_type_h |
---|
| 3 | |
---|
| 4 | #include <string> |
---|
| 5 | #include <map> |
---|
| 6 | #include <utility> |
---|
[138] | 7 | #include <cassert> |
---|
[144] | 8 | #include <stdint.h> |
---|
[71] | 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | |
---|
| 13 | typedef double counter_t ; |
---|
| 14 | |
---|
| 15 | typedef enum{add, sub, mul, div, inc, dec} operator_t; |
---|
| 16 | |
---|
[146] | 17 | #ifdef STATISTICS |
---|
| 18 | |
---|
| 19 | typedef enum{TYPE_VARIABLE, TYPE_COUNTER} counter_type_t; |
---|
| 20 | |
---|
[71] | 21 | //typedef std::pair<operator_t, std::string> pair_operator_string_t; |
---|
| 22 | //typedef std::pair<std::string, operator_t> pair_string_operator_t; |
---|
| 23 | |
---|
[138] | 24 | class counters_t |
---|
| 25 | { |
---|
| 26 | private : const uint32_t _nb_counter; |
---|
| 27 | private : counter_t ** _counter; |
---|
| 28 | |
---|
| 29 | public : counters_t (uint32_t nb_counter): |
---|
| 30 | _nb_counter (nb_counter+1) |
---|
| 31 | { |
---|
| 32 | assert(nb_counter>0); |
---|
| 33 | |
---|
| 34 | _counter = new counter_t * [_nb_counter]; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // public : counters_t (const counters_t & x): |
---|
| 38 | // _nb_counter (x._nb_counter) |
---|
| 39 | // { |
---|
| 40 | // _counter = new counter_t [_nb_counter]; |
---|
| 41 | |
---|
| 42 | // for (uint32_t i=0; i<_nb_counter; ++i) |
---|
| 43 | // _counter[i] = x._counter[i]; |
---|
| 44 | // } |
---|
| 45 | |
---|
| 46 | public : ~counters_t (void) |
---|
| 47 | { |
---|
| 48 | delete [] _counter; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | public : void set_counter (counter_t * counter, |
---|
| 52 | uint32_t index) |
---|
| 53 | { |
---|
| 54 | assert((index >= 0) and (index < _nb_counter)); |
---|
| 55 | |
---|
| 56 | _counter [index] = counter; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | // public : friend const counters_t operator+ (const counters_t & left, |
---|
| 60 | // const uint32_t right) |
---|
| 61 | // { |
---|
| 62 | // assert((right >= 0) and (right <= left._nb_counter)); |
---|
| 63 | |
---|
| 64 | // counters_t tmp=left; |
---|
| 65 | |
---|
| 66 | // tmp._counter[right] ++; |
---|
| 67 | |
---|
| 68 | // return tmp; |
---|
| 69 | // } |
---|
| 70 | |
---|
| 71 | public : const counters_t & operator+= (const uint32_t value) |
---|
| 72 | { |
---|
| 73 | assert((value >= 0) and (value <= _nb_counter)); |
---|
| 74 | |
---|
| 75 | (*_counter[value]) ++; |
---|
| 76 | |
---|
| 77 | return *this; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | }; |
---|
| 81 | |
---|
[146] | 82 | #endif |
---|
| 83 | |
---|
[71] | 84 | }; |
---|
| 85 | }; |
---|
| 86 | #endif |
---|