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