line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OPTIMADE::Filter::Known; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
34
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
158
|
|
4
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
202
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
29
|
use parent 'OPTIMADE::Filter::Modifiable'; |
|
5
|
|
|
|
|
27
|
|
|
5
|
|
|
|
|
22
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
4
|
|
|
4
|
0
|
11
|
my( $class, $is_known, $property ) = @_; |
10
|
4
|
|
|
|
|
17
|
return bless { is_known => $is_known, property => $property }, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub is_known |
14
|
|
|
|
|
|
|
{ |
15
|
6
|
|
|
6
|
0
|
14
|
my( $self, $is_known ) = @_; |
16
|
6
|
|
|
|
|
11
|
my $previous_is_known = $self->{is_known}; |
17
|
6
|
50
|
|
|
|
15
|
$self->{is_known} = $is_known if defined $is_known; |
18
|
6
|
|
|
|
|
26
|
return $previous_is_known; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub property |
22
|
|
|
|
|
|
|
{ |
23
|
16
|
|
|
16
|
0
|
29
|
my( $self, $property ) = @_; |
24
|
16
|
|
|
|
|
34
|
my $previous_property = $self->{property}; |
25
|
16
|
100
|
|
|
|
34
|
$self->{property} = $property if defined $property; |
26
|
16
|
|
|
|
|
45
|
return $previous_property; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub to_filter |
30
|
|
|
|
|
|
|
{ |
31
|
4
|
|
|
4
|
0
|
11
|
my( $self ) = @_; |
32
|
4
|
|
|
|
|
11
|
$self->validate; |
33
|
4
|
100
|
|
|
|
12
|
return $self->property->to_filter . ' IS ' . |
34
|
|
|
|
|
|
|
($self->is_known ? 'KNOWN' : 'UNKNOWN'); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub to_SQL |
38
|
|
|
|
|
|
|
{ |
39
|
2
|
|
|
2
|
0
|
7
|
my( $self, $options ) = @_; |
40
|
2
|
|
|
|
|
5
|
$self->validate; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
7
|
my( $sql, $values ) = $self->property->to_SQL( $options ); |
43
|
2
|
100
|
|
|
|
7
|
$sql = "$sql IS " . ($self->is_known ? 'NOT NULL' : 'NULL'); |
44
|
2
|
50
|
|
|
|
6
|
if( wantarray ) { |
45
|
2
|
|
|
|
|
8
|
return ( $sql, $values ); |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
|
|
|
|
0
|
return $sql; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub modify |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
54
|
0
|
|
|
|
|
0
|
my $code = shift; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$self->property( $self->property->modify( $code, @_ ) ); |
57
|
0
|
|
|
|
|
0
|
return $code->( $self, @_ ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub validate |
61
|
|
|
|
|
|
|
{ |
62
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
63
|
6
|
50
|
|
|
|
12
|
die 'property undefined for OPTIMADE::Filter::Known' if !$self->property; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |