#include "execContext.h" #include "logger.h" #include "presenter.h" #include "rowSet.h" #include "iHaveParameters.h" void ExecContext::logMessage(bool writeLog, const Glib::ustring & g, const Glib::ustring & m) { if (writeLog) { Logger()->messagebf(LOG_NOTICE, "%s: %s: %s", __PRETTY_FUNCTION__, g, m); } messages.push_back(std::make_shared(g, m)); } void ExecContext::addContextData(const MultiRowSetPresenter * p) const { // Message log p->addNewRowSet("messages", Scripts::scriptNamespacePrefix); p->addNewArray("message", true); for (const Messages::value_type & m : messages) { p->addNewRow("message"); p->addAttribute("group", m->group); p->addAttribute("text", m->message); p->finishRow(); } p->finishArray(true); p->finishRowSet(); } ExecContext::Message::Message(const Glib::ustring & g, const Glib::ustring & m) : group(g), message(m) { } void ExecContext::RowValuesPush(const RowState * rs) { rowValuesStack.push_back(rs); } void ExecContext::RowValuesPop() { rowValuesStack.pop_back(); } const RowState * ExecContext::RowValues(size_t depth) const { if (depth < 1 || depth > rowValuesStack.size()) { throw RowSet::ParentOutOfRange(depth); } return rowValuesStack.at(rowValuesStack.size() - depth); } void ExecContext::ParametersPush(const IHaveParameters * p) { parameterStack.push_back(p); } void ExecContext::ParametersPop() { parameterStack.pop_back(); } VariableType ExecContext::getScopedParameter(const Glib::ustring & name) { for(auto ihp = parameterStack.rbegin(); ihp != parameterStack.rend(); ++ihp) { auto i = (*ihp)->allParameters().find(name); if (i != (*ihp)->allParameters().end()) { return i->second(this); } } throw ParamNotFound(name); }