ProcessSumIntoTableRange.cc
3.74 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
/*
* ProcessSumIntoTableRange.cc
*
* Created on: Oct 6, 2016
* Author: AKKA IS
*/
#include <stdlib.h>
#include <string>
#include <boost/lexical_cast.hpp>
#include "DicError.hh"
#include "AMDA_exception.hh"
#include "Operation.hh"
#include "ParameterManager.hh"
#include "ProcessSumIntoTableRange.hh"
#include "SumIntoTableRangeCreator.hh"
#include "ParamMgr.hh"
#include "ParameterCreatorFromExpression.hh"
using namespace std;
using namespace boost;
using namespace log4cxx;
namespace AMDA {
namespace Parameters {
ProcessSumIntoTableRange::ProcessSumIntoTableRange(Parameter ¶meter) : MultiParamProcess_CRTP(parameter), _dim1Table(NULL), _dim2Table (NULL) {
}
ProcessSumIntoTableRange::ProcessSumIntoTableRange(const ProcessSumIntoTableRange& pProcess, Parameter ¶meter)
: MultiParamProcess_CRTP(pProcess,parameter), _dim1Table(NULL), _dim2Table (NULL) {
}
ProcessSumIntoTableRange::~ProcessSumIntoTableRange() {
}
void ProcessSumIntoTableRange::establishConnection() {
ParameterCreatorFromExpression creator(_parameter.getParameterManager());
ParameterSPtr lParameter = creator.getOneParameterFromExpression(_parameter,_expression);
_paramNameList[lParameter->getId()].first = lParameter;
AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(lParameter->getInfoId());
if (paramInfo != nullptr)
{
std::map<int, boost::shared_ptr<AMDA::Info::ParamTable>>& paramTables = paramInfo->getTables();
if (paramTables.find(0) != paramTables.end())
_dim1Table = paramInfo->getTable(0).get();
else
_dim1Table = NULL;
if (paramTables.find(1) != paramTables.end())
_dim2Table = paramInfo->getTable(1).get();
else
_dim2Table = NULL;
if (_dim1Table != NULL) {
if (_dim1Table->isVariable()) {
for (std::map<std::string, std::string>::iterator it = _dim1Table->getTableParams().begin(); it != _dim1Table->getTableParams().end(); ++it) {
_paramNameList[it->second].first = _parameter.getParameterManager().getParameter(it->second);
}
}
}
if (_dim2Table != NULL) {
if (_dim2Table->isVariable()) {
for (std::map<std::string, std::string>::iterator it = _dim2Table->getTableParams().begin(); it != _dim2Table->getTableParams().end(); ++it) {
_paramNameList[it->second].first = _parameter.getParameterManager().getParameter(it->second);
}
}
}
}
MultiParamProcess::establishConnection();
}
TimeStamp ProcessSumIntoTableRange::init() {
if (_attributList.size() < 3) {
BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessSumIntoTableRange::init required at least 3 attributes'")));
}
int relatedDim = atoi(_attributList[0].c_str());
double minRange = atof(_attributList[1].c_str());
double maxRange = atof(_attributList[2].c_str());
AMDA::Info::ParamTable* tablePtr = NULL;
switch (relatedDim) {
case 0:
tablePtr = _dim1Table;
break;
case 1:
tablePtr = _dim2Table;
break;
default:
tablePtr = NULL;
}
if (tablePtr == NULL) {
BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessSumIntoTableRange::init Cannot retrieve related table")));
}
TimeStamp timeStamp = MultiParamProcess::init();
ParamData* lmainParamInput = _paramNameList.begin()->second.first->getParamData(this).get();
SumIntoTableRangeCreator lSumIntoTableRangeCreator(*this, *lmainParamInput, minRange, maxRange, tablePtr);
_operation = lSumIntoTableRangeCreator.getOperation();
_paramData = ParamDataSPtr(_operation->getParamOutput());
_paramData->setMinSampling(lmainParamInput->getMinSampling());
return timeStamp;
}
} /* namespace Parameters */
} /* namespace AMDA */