CalibrationInfoWriter.cc
2.11 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
/*
* CalibrationInfo.cc
*
* Created on: Dec 24, 2012
* Author: f.casimir
*/
#include "DicError.hh"
#include "CalibrationInfoWriter.hh"
#include "Process.hh"
#include "ServicesServer.hh"
namespace AMDA {
namespace Parameters {
CalibrationInfoWriter::CalibrationInfoWriter() {
}
CalibrationInfoWriter::~CalibrationInfoWriter() {
}
void CalibrationInfoWriter::operator()(Parameter& pParameter) {
/// Parse _expression
CalibrationInfoWriter::Parser lParser(_expression);
if (lParser._functionName != "" ) {
/// Execute function
CalibrationInfoProcess functor = ServicesServer::getInstance()->getService<CalibrationInfoProcess>(lParser._functionName);
if ( ! functor) {
std::stringstream oss;
oss << "Operation: '" << lParser._functionName << "' not exist";
BOOST_THROW_EXCEPTION(Process_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(oss.str()));
} else {
functor(pParameter,lParser._attributeList);
}
}
}
CalibrationInfoWriter::Parser::Parser( std::string pExpression) : _state(funcName){
std::string::iterator it = pExpression.begin();
std::string attribute = "";
while((it != pExpression.end()) && ( _state!=undefined)) {
switch(*it) {
case '(':
if (_state==funcName) { _state=attributeVal; } else { _state=undefined; }
break;
case ')':
if (_state==attributeVal) { _state=end; } else { _state=undefined; }
if ( ! attribute.empty() ) { _attributeList.push_back(attribute); attribute=""; }
break;
case ' ':
break;
case ',':
_attributeList.push_back(attribute); attribute="";
break;
default:
if (isAuthorisedSymbol(*it)) {
switch(_state) {
case funcName: _functionName.append(1, *it); break;
case attributeVal: attribute.append(1, *it); break;
default:
_state=undefined;
}
} else {
_state=undefined;
}
break;
}
++it;
}
if (_state==undefined) {
BOOST_THROW_EXCEPTION(Process_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("Error to parse expression: ")+pExpression));
}
}
} /* namespace Parameters */
} /* namespace AMDA */