NAME
Schedule::Activity::NodeFilter - Evaluate if attributes match logical expressions
SYNOPSIS
my $filter=Schedule::Activity::NodeFilter->new(
f =>'value/avg/elapsed'
attr =>'attribute name'
op =>'lt/gt/le/ge/eq/ne'
value=>number
#
boolean=>'and/or/nand'
filters=>[...]
);
if($filter->matches($tm,%attributes)) { ... }
DESCRIPTION
TODO.
VALUE FILTERS
Attribute values
A filter that directly checks attribute values as attribute op value
can be created with
f =>'value',
attr =>'name',
op =>'lt/gt/le/ge/eq/ne',
value=>number,
It is not necessary to pass f=value
, which is the default. If the attribute value is undefined, the match is false. All other operators are numeric and are self explanatory. (This might change, but currently there is no proposal/use case to support setting attributes with string values.)
Attribute averages
(not yet available) A filter that uses the current average value of an attribute as average op value
can be created with
f =>'avg',
attr =>'name',
op =>'operator',
value=>number,
Elapsed time
To control "time between actions", a filter can be used to check the elapsed time since an integer attribute was stored by evaluating (now-attribute time) op value
with
f =>'elapsed',
attr =>'name',
op =>'operator'
value=>seconds,
For any attribute, the most recent recorded event is used as the attribute time. To record a timestamp for an integer attribute without changing its value, use incr=0
.
BOOLEAN EXPRESSIONS
A boolean filter supports AND, OR, and NAND expressions as follows:
boolean=>'and/or/nand',
filters=>[...],
The filters
are any list of one or more filters of any type. That is, AND
is the conjunction over all filters in the list (all must be true). The OR
is the disjunction over all filters in the list (at least one must be true).
The Boolean NOT may be implemented as boolean=nand, filters=[filter]
, because the NAND operator is implemented via DeMorgan's Laws as !A || !B || ...
.
All operators support short-circuiting.