Skip to content
Snippets Groups Projects
Commit ffafa97f authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Construcion of FunExecContext from ActionExecContext.

Intentionally left implicit.
parent 5eb3ac0d
No related merge requests found
......@@ -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,
......
......@@ -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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment