ParamTableProcess.cc
3.26 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
/*
* ParamTableProcess.cc
*
* Created on: Nov 23, 2022
* Author: AKKA
*/
#include "ParamTableProcess.hh"
#include <stdlib.h>
#include <string>
#include "AMDA_exception.hh"
#include "DicError.hh"
#include "ParameterManager.hh"
#include "ParamMgr.hh"
#include "ParamTableOperation.hh"
namespace AMDA {
namespace Parameters {
ParamTableProcess::ParamTableProcess(Parameter ¶meter)
: MultiParamProcess_CRTP(parameter), _dim(0) {
}
ParamTableProcess::ParamTableProcess(const ParamTableProcess& pProcess, Parameter ¶meter)
: MultiParamProcess_CRTP(pProcess,parameter), _dim(pProcess._dim) {
//Establish Connection Without Parse
MultiParamProcess::establishConnection();
}
ParamTableProcess::~ParamTableProcess() {
}
void ParamTableProcess::establishConnection() {
std::vector<std::string> strs;
boost::split(strs, _expression, boost::is_any_of("|"));
if (strs.size() != 2) {
BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ParamTableProcess::establishConnection cannot retrieve paramId or dim")));
}
std::string paramId = strs[0];
_dim = std::stoi(strs[1].c_str());
_paramSPtr = _parameter.getParameterManager().getParameter(paramId);
_paramNameList[_paramSPtr->getId()].first = _paramSPtr;
AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_paramSPtr->getInfoId());
if (paramInfo == nullptr) {
BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ParamTableProcess::establishConnection cannot retrieve param info")));
}
_paramTable = paramInfo->getTable(_dim);
std::map<std::string, std::string> tableParams = _paramTable->getTableParams(&_parameter.getParameterManager());
for (std::map<std::string, std::string>::iterator it = tableParams.begin(); it != tableParams.end(); ++it) {
AMDA::Parameters::ParameterSPtr p = _parameter.getParameterManager().getParameter(it->second);
_paramNameList[it->second].first = p;
}
MultiParamProcess::establishConnection();
}
TimeStamp ParamTableProcess::init() {
TimeStamp timeStamp = MultiParamProcess::init();
//_parameter.init(this, _timeIntervalList);
this->setOperation((Operation*)(new AMDA::Parameters::ParamTable::ParamTableOperation(*this)));
this->getParamData().reset( this->getOperation()->getParamOutput());
return timeStamp;
}
boost::shared_ptr<AMDA::Info::ParamTable> ParamTableProcess::getParamTable() {
return _paramTable;
}
void ParamTableProcess::updateInfo(Parameter & parameter)
{
MultiParamProcess::updateInfo(parameter);
LOG4CXX_DEBUG(_logger, "ParamTableProcess::updateInfo - " << parameter.getId());
//Param info
AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(parameter.getInfoId(),true);
if (paramInfo != nullptr)
{
paramInfo->resetLinkedParamList();
std::string processDescription = "Table of ";
processDescription += _paramSPtr->getInfoId();
processDescription += " dimension ";
processDescription += std::to_string(_dim);
paramInfo->setProcessDescription(processDescription);
}
}
} /* namespace Parameters */
} /* namespace AMDA */