| 1 | package Net::Lyskom::Object; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | Object - Net::Lyskom::Object | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | use base qw{Net::Lyskom::Object}; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Ur-object from which all other Net::Lyskom object inherits. Is not | ||||||||||||||||||||||||||||
| 17 | particularly useful on its own. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head2 Methods | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =over | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =item ->as_string | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | Returns the current object as a string, serialized via Data::Dumper. | ||||||||||||||||||||||||||||
| 26 | Mostly useful for debugging purposes. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =item ->gen_call_boolean($call,@args) | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Sends call number $call with arguments @args to the server. Returns | ||||||||||||||||||||||||||||
| 31 | undef if the server indicates a failure and the object itself if it | ||||||||||||||||||||||||||||
| 32 | indicates success. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =item ->gen_call_scalar($call,@args) | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | As the previous, except that it returns a simple scalar from the | ||||||||||||||||||||||||||||
| 37 | server call. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =back | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | my $s = shift; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return Dumper $s; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Generic server call with succeed/fail return semantics | ||||||||||||||||||||||||||||
| 51 | 4 | ▶ | sub gen_call_boolean { | ||||||||||||||||||||||||||
|
Subroutine
gen_call_boolean: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 4 | my $call = shift; | |||||||||||||||||||||||||||
| 54 | 4 | my $this = $self->{refno}++; | |||||||||||||||||||||||||||
| 55 | 4 | my @res; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | $self->send( | |||||||||||||||||||||||||||
| 58 | join " ", $this,$call,@_,"\x0a" | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | 4 | @res = $self->getres; | |||||||||||||||||||||||||||
| 61 | 4 | ▶ | if ($self->is_error(@res)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | return 0; | |||||||||||||||||||||||||||
| 63 | } else { | ||||||||||||||||||||||||||||
| 64 | 4 | return $self; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | sub gen_call_scalar { | ||||||||||||||||||||||||||
|
Subroutine
gen_call_scalar: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 2 | my $call = shift; | |||||||||||||||||||||||||||
| 71 | 2 | my $this = $self->{refno}++; | |||||||||||||||||||||||||||
| 72 | 2 | my @res; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | $self->send( | |||||||||||||||||||||||||||
| 75 | join " ", $this,$call,@_,"\x0a" | ||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||
| 77 | 2 | @res = $self->getres; | |||||||||||||||||||||||||||
| 78 | 2 | ▶ | if ($self->is_error(@res)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | return 0; | |||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||
| 81 | 2 | return $res[1]; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 7 | ▶ | sub server_call { | ||||||||||||||||||||||||||
|
Subroutine
server_call: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 7 | ▶ | if (ref($_[0]) && ref($_[0]) eq "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq "ARRAY"
MC/DC50%1/2
ref $_[0] and ref $_[0] eq "ARRAY"
ref $_[0]
ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 89 | 1 | my ($str, @res); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1 | foreach (@{$_[0]}) { | |||||||||||||||||||||||||||
| 92 | 1 | $str .= join " ",$self->{refno}++,@{$_},"\x0a"; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 1 | $self->send($str); | |||||||||||||||||||||||||||
| 95 | 1 | foreach (@{$_[0]}) { | |||||||||||||||||||||||||||
| 96 | 1 | my @tmp = $self->getres; | |||||||||||||||||||||||||||
| 97 | 1 | ▶ | splice @tmp, 0, 1, ($1,$2) if $tmp[0] =~ /^(=|%)(\d+)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 1 | push @res,[@tmp]; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | @res = sort {$a->[1] <=> $b->[1]} @res; | |||||||||||||||||||||||||||
| 101 | 1 | foreach (@res) { | |||||||||||||||||||||||||||
| 102 | 1 | my ($a,$b) = splice @{$_},0,2; | |||||||||||||||||||||||||||
| 103 | 1 | unshift @{$_},$a.$b; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 1 | return @res; | |||||||||||||||||||||||||||
| 106 | } else { | ||||||||||||||||||||||||||||
| 107 | 6 | my $this = $self->{refno}++; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 6 | $self->send( | |||||||||||||||||||||||||||
| 110 | join " ", $this, @_, "\x0a" | ||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||
| 112 | 6 | return $self->getres; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1 | 1; | |||||||||||||||||||||||||||