line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OPTIMADE::Filter::Known; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
34
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
164
|
|
4
|
5
|
|
|
5
|
|
62
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
202
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
30
|
use parent 'OPTIMADE::Filter::Modifiable'; |
|
5
|
|
|
|
|
27
|
|
|
5
|
|
|
|
|
25
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
4
|
|
|
4
|
0
|
9
|
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
|
15
|
my( $self, $is_known ) = @_; |
16
|
6
|
|
|
|
|
11
|
my $previous_is_known = $self->{is_known}; |
17
|
6
|
50
|
|
|
|
14
|
$self->{is_known} = $is_known if defined $is_known; |
18
|
6
|
|
|
|
|
23
|
return $previous_is_known; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub property |
22
|
|
|
|
|
|
|
{ |
23
|
16
|
|
|
16
|
0
|
30
|
my( $self, $property ) = @_; |
24
|
16
|
|
|
|
|
32
|
my $previous_property = $self->{property}; |
25
|
16
|
100
|
|
|
|
34
|
$self->{property} = $property if defined $property; |
26
|
16
|
|
|
|
|
43
|
return $previous_property; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub to_filter |
30
|
|
|
|
|
|
|
{ |
31
|
4
|
|
|
4
|
0
|
12
|
my( $self ) = @_; |
32
|
4
|
|
|
|
|
13
|
$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
|
5
|
my( $self, $options ) = @_; |
40
|
2
|
|
|
|
|
6
|
$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
|
|
|
|
7
|
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
|
8
|
my $self = shift; |
63
|
6
|
50
|
|
|
|
13
|
die 'property undefined for OPTIMADE::Filter::Known' if !$self->property; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |