Remote/Client.pm

filter: Statementstmt 41.1% 28 / 68 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 9 / 18 Podpod 71.4% 5 / 7 totaltotal 37.1% 42 / 113 SCAR 37.1
CC
10
Cov
33%
close
20.0
data
12.0
exception
12.0
CRAP 40.7
« Remote/Server.pm ↑ Summary Remote/DualvarMapping.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Net::IMP::Remote::Client;
5 1 ▶use base 'Net::IMP::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use fields qw(id);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Net::IMP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Net::IMP::Remote::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Net::IMP::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new_factory {
14 0 ▶ my ($class,%args) = @_;
Subroutine new_factory: not called CC=1 SCAR=6.9
Pod documented
15 0 my $self = $class->SUPER::new_factory(%args);
16  
17 0 weaken( my $wself = $self );
18 $self->{factory_args}{conn}->nextop({
19 IMPRPC_EXCEPTION+0 => [ \&exception, $wself ],
20 IMPRPC_RESULT+0 => sub {
21 0 ▶ my $id = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
22 0 my $obj = $wself->{factory_args}{conn}->get_analyzer($id);
23 0 ▶ $obj->run_callback(\@_) if ref $obj;
Branch: 1 branch
BranchTrueFalseTotal
if ref $obj 0 0 0
24 },
25 0 }, -1 );
26 0 return $self;
27 }
28  
29 sub get_interface {
30 0 ▶ my ($self,@if) = @_;
Subroutine get_interface: not called CC=2 SCAR=17.9
Pod documented
31 0 my @analyzer_if;
32 0 ▶ if ( $self->{factory_args}{conn}->rpc(
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'factory_args'}{'conn'}->rpc([16385, @if], {16641, [\&Net::IMP::Remote::Client::exception, $self], 16642, \@analyzer_if})) { } 0 0 0
33 [ IMPRPC_GET_INTERFACE, @if ],
34 {
35 IMPRPC_EXCEPTION+0 => [ \&exception, $self ],
36 IMPRPC_INTERFACE+0 => \@analyzer_if,
37 }
38 )) {
39 0 return @analyzer_if;
40 } else {
41 return
42 0 }
43 }
44  
45 sub set_interface {
46 0 ▶ my ($self,$if) = @_;
Subroutine set_interface: not called CC=1 SCAR=6.9
Pod documented
47 0 $self->{factory_args}{conn}->rpc([ IMPRPC_SET_INTERFACE,$if ]);
48 0 return $self;
49 }
50  
51 sub new_analyzer {
52 0 ▶ my ($self,%ctx) = @_;
Subroutine new_analyzer: not called CC=1 SCAR=6.9
Pod documented
53 0 my $obj = $self->SUPER::new_analyzer(%ctx);
54 0 my $conn = $self->{factory_args}{conn};
55 0 my $id = $obj->{id} = $conn->weak_add_analyzer($obj);
56 0 $conn->rpc([ IMPRPC_NEW_ANALYZER,$id,\%ctx ]);
57 0 return $obj;
58 }
59  
60 sub data {
61 0 ▶ my ($self,$dir,$data,$offset,$type) = @_;
Subroutine data: not called CC=3 SCAR=24.8
Pod documented
62 $self->{factory_args}{conn}->rpc([ IMPRPC_DATA,
63 0 ▶ $self->{id} || die("data called on factory not analyzer"),
Condition0%0/4
$self->{'id'} || die('data called on factory not analyzer')
l!l
00
$type // "imp.data.stream"
l!l
00
MC/DC0%0/1
$self->{'id'} || die('data called on factory not analyzer')
$self->{'id'}
MC/DC0%0/1
$type // "imp.data.stream"
$type
Truth table0%0/2
A
A= $self->{'id'}
Aresult
11
00
Truth table0%0/2
A
A= $type
Aresult
11
00
64 $dir,$offset,$type//IMP_DATA_STREAM,$data ]);
65 }
66  
67 sub close {
68 0 ▶ my ($self,$why) = @_;
Subroutine close: not called CC=4 SCAR=30.0
Pod undocumented
69 0 debug("destroy @_");
70 0 ▶ my $conn = $self->{factory_args}{conn} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $conn = $self->{"factory_args"}{"conn"} or return 0 0 0
71 0 ▶ if ( my $id = $self->{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $id = $self->{'id'}) { } 0 0 0
72 0 ▶ warn "[$id] $why\n" if $why;
Branch: 1 branch
BranchTrueFalseTotal
if $why 0 0 0
73 0 $conn->del_analyzer($id);
74 0 $conn->rpc([ IMPRPC_DEL_ANALYZER,$id ]);
75 } else {
76 0 $self->{factory_args}{conn}->close($why);
77 }
78 0 1;
79 }
80  
81 0 ▶sub DESTROY { goto &close }
Subroutine DESTROY: not called CC=1 SCAR=6.9
82  
83 sub exception {
84 0 ▶ my ($self,$id,$msg) = @_;
Subroutine exception: not called CC=3 SCAR=24.8
Pod undocumented
85 0 ▶ if ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id) { } 0 0 0
86 0 ▶ if ( my $obj = $self->{factory_args}{conn}->get_analyzer($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $self->{'factory_args'}{'conn'}->get_analyzer($id)) { } 0 0 0
87 0 $obj->close($msg);
88 } else {
89 0 warn "[$id/unknown] $msg\n"
90 }
91 } else {
92 0 $self->close("global exception: $msg");
93 }
94 }
95  
96  
97  
98 1 1;
99 __END__
« Remote/Server.pm ↑ Summary Remote/DualvarMapping.pm »