/* * 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(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 */