NAME

Kvasir::Engine - Engine declaration

SYNOPSIS

use Kvasir::Engine;

my $engine = Kvasir::Engine->new();
$engine->add_hook(hook1 => "MyApp::GetMoreData");
$engine->add_rule(rule1 => "MyApp::Rule");
$engine->add_action(action1 => "MyApp::Action");
$engine->add_rule_action(rule1 => "action1");
$engine->run();

DESCRIPTION

This class defines a Kvasir "engine". Altho it is possible using this class directly it is more readable using the declarative interface in Kvasir::Declare or loading engines using an engine loader class (which is currently not available).

INTERFACE

CLASS METHODS

new

Creates a new engine.

INSTANCE METHODS

run ( $work_callback )

Runs the engine.

Actions

actions

Returns the names of all registered actions.

has_action ( NAME )

Checks if the engine has a registered action with the given NAME.

add_action ( NAME => ACTION )

Registers the ACTION as NAME in the engine.

Hooks

hooks

Returns the names of all registered hooks.

has_hook ( NAME )

Checks if the engine has a registered hook with the given NAME.

add_hook ( NAME => HOOK )

Registers the HOOK as NAME in the engine.

add_pre_hook ( NAME )

Adds the hook with the given NAME to the list of hooks to run before each iteration.

add_post_hook ( NAME )

Adds the hook with the given NAME to the list of hooks to run after each iteration.

Inputs

inputs

Returns the names of all registered inputs

has_input ( NAME )

Checks if the engine has a registered input with the given NAME.

add_input ( NAME => INPUT )

Registers the INPUT as NAME in the engine.

Outputs

outputs

Returns the names of all registered outputs

has_output ( NAME )

Checks if the engine has a registered output with the given NAME.

add_output ( NAME => OUTPUT )

Registers the OUTPUT as NAME in the engine.

Rules

rules

Returns the names of all registered rules

has_rule ( NAME )

Checks if the engine has a registered rule with the given NAME.

add_rule ( NAME => OUTPUT )

Registers the OUTPUT as NAME in the engine.

add_rule_action ( NAME => ACTION )

Connects the rule NAME to the action ACTION.

rule_order

Returns a list of names matching the rules in the order they'll be evaluated.

set_rule_order ( LIST )

Sets which order the rules should be evaluated. The list should be the names of the rules.