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