X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FSolver.pm;h=f1579a2c496a230514e08372268a5e42742eca04;hb=e28f7460084f26d463047e4791cd0671c803ace1;hp=753abe5b3b87932dfd5fe5a8cfd87400993d3c80;hpb=6d5315405254a96b847add9e83a642cc9649db69;p=scpubgit%2FDKit.git diff --git a/lib/DX/Solver.pm b/lib/DX/Solver.pm index 753abe5..f1579a2 100644 --- a/lib/DX/Solver.pm +++ b/lib/DX/Solver.pm @@ -16,7 +16,9 @@ has rule_set => ( has facts => (is => 'ro', default => sub { {} }); -has observation_policy => (is => 'ro'); +has observation_policy => (is => 'rw'); + +has action_callback => (is => 'rw'); sub query { my ($self, @terms) = @_; @@ -64,7 +66,9 @@ sub _solve { sub run_action { my ($self, $action) = @_; - warn +(split('::', ref($action)))[-1]."\n"; + if (my $cb = $self->action_callback) { + $cb->($action); + } my @invalidate = $action->run; while (my ($type, $value) = splice @invalidate, 0, 2) { $self->facts->{$type}->remove_value($value);