StatisticOperation.hh
2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* StatisticOperation.hh
*
* Created on: 4 nov. 2012
* Author: AKKA IS
*/
#ifndef STATISTICOPERATION_HH_
#define STATISTICOPERATION_HH_
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include "StatisticData.hh"
namespace AMDA {
namespace Parameters {
class StatisticProcess; ///< @see StatisticProcess
class ParamDataIndexInfo; ///< @see ParamDataIndexInfo
/**
* @brief Interface of StatisticProcess operation
* @details must be implemented in an StatisticProcess implementation to compute statistic data
* @see Process
*/
class StatisticOperationBase {
public:
/**
* @brief default constructor
*/
StatisticOperationBase(StatisticProcess& process) :
_process(process){
}
/**
* @brief destructor
*/
virtual ~StatisticOperationBase() {}
/**
* @brief compute statistic data
* @detail pParamDataIndexInfo contain input description data
*/
virtual void compute(ParamDataIndexInfo &pParamDataIndexInfo) = 0;
/*
* @brief finalize computation - must be call before to get result
*/
virtual void finalizeCompute(void)
{
//Nothing to do
}
/*
* @brief push statistic result in two string vectors (one for the statistic computation, the other one for the coverage)
* ideal is the ideal number of data in the current interval (in relation to the parameter sampling time)
*/
virtual void pushResult(std::vector<std::string>& result, std::vector<std::string>& coverage, int ideal, bool isCoverageIndependantOfResultType,int index) = 0;
/**
* @brief Reset static data to process on another data flow.
*/
virtual void reset() {
//Nothing to do
}
/**
* @brief Get the result dimensiond efinition.
* If forCoverage is true, the given dimension is for the coverage
*/
virtual std::string getResultDimDefinition(bool forCoverage = false) = 0;
protected:
/**
* @brief Reference on parent process
*/
StatisticProcess &_process;
};
template<typename TStatisticData>
class StatisticOperation : public StatisticOperationBase
{
public:
/*
* @brief constructor
*/
StatisticOperation(StatisticProcess& process) :
StatisticOperationBase(process),
_resultData()
{
}
/*
* @brief destructor
*/
virtual ~StatisticOperation(void)
{
}
/*
* @biref Get statistic result
*/
TStatisticData getStatisticResult(void)
{
return _resultData;
}
/*
* @brief push result in a string vector
*/
void pushResult(std::vector<std::string>& result, std::vector<std::string>& coverage, int ideal, bool isCoverageIndependantOfResultType, int index = -1)
{
pushStatisticDataInVectorString(result, coverage, _resultData, ideal, isCoverageIndependantOfResultType, index);
}
protected:
TStatisticData _resultData;
};
}
}
#endif /* STATISTICOPERATION_HH_ */