From ffafa97fc4c22b19d85c661d9acde5eec5e77693 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(B-4.4.46a)> Date: Tue, 11 Jan 2011 18:53:57 +0100 Subject: [PATCH] Construcion of FunExecContext from ActionExecContext. Intentionally left implicit. --- libwccl/ops/funexeccontext.h | 11 ++++++++++- libwccl/ops/rule.cpp | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libwccl/ops/funexeccontext.h b/libwccl/ops/funexeccontext.h index 4a41ccc..43e039c 100644 --- a/libwccl/ops/funexeccontext.h +++ b/libwccl/ops/funexeccontext.h @@ -4,6 +4,7 @@ #include <boost/noncopyable.hpp> #include <libwccl/variables.h> #include <libwccl/sentencecontext.h> +#include <libwccl/ops/actionexeccontext.h> namespace Wccl { @@ -11,7 +12,8 @@ namespace Wccl { * Class holding execution context of a functional operator * i.e. state that the function should operate on. */ -class FunExecContext : public boost::noncopyable { +class FunExecContext : boost::noncopyable +{ public: FunExecContext( const SentenceContext& sentence_context, const boost::shared_ptr<Variables>& vars) @@ -19,6 +21,13 @@ public: { } + FunExecContext(const ActionExecContext& action_exec_context) + : sentence_context_(action_exec_context.sentence_context()), + vars_(action_exec_context.variables()) + { + // this is intentionally left implicit :) + } + /** * @returns Context of a sentence the operator is applied to. * @note Functional operators should not change sentence state, diff --git a/libwccl/ops/rule.cpp b/libwccl/ops/rule.cpp index 0ff6262..ba843bd 100644 --- a/libwccl/ops/rule.cpp +++ b/libwccl/ops/rule.cpp @@ -16,8 +16,8 @@ Bool Rule::execute(SentenceContext &sentence_context) "Current position is outside boundaries of the sentence."); } Bool changed(false); - if(condition_->apply(FunExecContext(sentence_context, variables_))->get_value()) { - ActionExecContext aec(sentence_context, variables_); + ActionExecContext aec(sentence_context, variables_); + if(condition_->apply(aec)->get_value()) { foreach(const boost::shared_ptr<Action>& action, *actions_) { if(action->execute(aec).get_value()) { changed.set_value(true); -- GitLab