| 1 | # -*- Perl -*- | ||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||
| 3 | # File: POE/Event/Message/Header.pm | ||||||||||||||||||||||||||||||||
| 4 | # Desc: A generic network message header class to use as a starting point. | ||||||||||||||||||||||||||||||||
| 5 | # Date: Mon Oct 10 10:10:59 2005 | ||||||||||||||||||||||||||||||||
| 6 | # Stat: Prototype, Experimental | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | package POE::Event::Message::Header; | ||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 3 | our $PACK = __PACKAGE__; | |||||||||||||||||||||||||||||||
| 14 | 3 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||
| 15 | ### @ISA = qw( ); | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | ### POE::Kernel; ## Don't use POE here! | ||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use POE::Event::Message::UniqueID; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 3 | my $IdClass = "POE::Event::Message::UniqueID"; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | sub new | ||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | { my($self,$hRef) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | $self = bless {}, ref($self)||$self; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | if ($hRef and $hRef =~ /HASH/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hRef and $hRef =~ /HASH/
MC/DC50%1/2
$hRef and $hRef =~ /HASH/
$hRef
$hRef =~ /HASH/
Truth table66%2/3
A and B
A= $hRefB= $hRef =~ /HASH/
| |||||||||||||||||||||||||||||||||
| 28 | 1 | foreach (keys %$hRef) { $self->{$_} = $hRef->{$_} } | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | $self->set('r2id', $self->id() ||0 ) unless $self->r2id(); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->id || 0
MC/DC0%0/1
$self->id || 0
$self->id
Truth table50%1/2
A
A= $self->id
| |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | } else { | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | # $self->set('r2id', undef ); # InResponseTo message id | ||||||||||||||||||||||||||||||||
| 35 | # $self->set('ttl', undef ); # message TimeToLive | ||||||||||||||||||||||||||||||||
| 36 | # $self->set('type', undef ); # message type | ||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 3 | $self->set('id', $IdClass->generate() ); # guaranteed unique message id | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 3 | return $self; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | sub set { $_[0]->{$_[1]}=$_[2] } # Note that the 'param' method | ||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 45 | 5 | ▶ | sub get { return( $_[0]->{$_[1]}||"" ) } # combines 'set' and 'get' | ||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$_[0]{$_[1]} || ''
MC/DC100%1/1
$_[0]{$_[1]} || ''
$_[0]{$_[1]}
Truth table100%2/2
A
A= $_[0]{$_[1]}
| |||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub param { $_[2] ? $_[0]->{$_[1]}=$_[2] : return( $_[0]->{$_[1]}||"" ) } | ||||||||||||||||||||||||||||||
|
Subroutine
param: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
Condition0%0/2
$_[0]{$_[1]} || ''
MC/DC0%0/1
$_[0]{$_[1]} || ''
$_[0]{$_[1]}
Truth table0%0/2
A
A= $_[0]{$_[1]}
| |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub setErr { return( $_[0]->{STATUS}=$_[1]||0, $_[0]->{ERROR}=$_[2]||"" ) } | ||||||||||||||||||||||||||||||
|
Subroutine
setErr: not called CC=3 SCAR=24.8
Pod
undocumented
Condition0%0/4
$_[1] || 0
$_[2] || ''
MC/DC0%0/1
$_[1] || 0
$_[1]
MC/DC0%0/1
$_[2] || ''
$_[2]
Truth table0%0/2
A
A= $_[1]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub status { return( $_[0]->{STATUS}||0, $_[0]->{ERROR}||"" ) } | ||||||||||||||||||||||||||||||
|
Subroutine
status: not called CC=3 SCAR=24.8
Pod
undocumented
Condition0%0/4
$_[0]{'STATUS'} || 0
$_[0]{'ERROR'} || ''
MC/DC0%0/1
$_[0]{'STATUS'} || 0
$_[0]{'STATUS'}
MC/DC0%0/1
$_[0]{'ERROR'} || ''
$_[0]{'ERROR'}
Truth table0%0/2
A
A= $_[0]{'STATUS'}
Truth table0%0/2
A
A= $_[0]{'ERROR'}
| |||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub stat { ( wantarray ? ($_[0]->{ERROR}||"") : ($_[0]->{STATUS} ||0) ) } | ||||||||||||||||||||||||||||||
|
Subroutine
stat: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
Condition0%0/4
$_[0]{"ERROR"} or ""
$_[0]{"STATUS"} or 0
MC/DC0%0/1
$_[0]{"ERROR"} or ""
$_[0]{"ERROR"}
MC/DC0%0/1
$_[0]{"STATUS"} or 0
$_[0]{"STATUS"}
Truth table0%0/2
A
A= $_[0]{"ERROR"}
Truth table0%0/2
A
A= $_[0]{"STATUS"}
| |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub err { return($_[0]->{ERROR}||"") } | ||||||||||||||||||||||||||||||
|
Subroutine
err: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
$_[0]{'ERROR'} || ''
MC/DC0%0/1
$_[0]{'ERROR'} || ''
$_[0]{'ERROR'}
Truth table0%0/2
A
A= $_[0]{'ERROR'}
| |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub del { delete $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||
|
Subroutine
del: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 3 | *delete = \&del; | |||||||||||||||||||||||||||||||
| 54 | 3 | *reset = \&del; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub id { $_[0]->get('id') } # unique message ID | ||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | sub r2id { $_[0]->get('r2id') } # orig. msg ID, in a response | ||||||||||||||||||||||||||||||
|
Subroutine
r2id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub ttl { $_[0]->param('ttl', $_[1]) } # message time-to-live | ||||||||||||||||||||||||||||||
|
Subroutine
ttl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub type { $_[0]->param('type', $_[1]) } # message type (reply | bcast) | ||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub mode { $_[0]->param('mode', $_[1]) } # response mode (post | call) | ||||||||||||||||||||||||||||||
|
Subroutine
mode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 3 | *rid = \&r2id; | |||||||||||||||||||||||||||||||
| 63 | 3 | *origId = \&r2id; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 3 | *setType = \&type; # Type: reply or bcast (default: reply) | |||||||||||||||||||||||||||||||
| 66 | 3 | *getType = \&type; # Type: reply or bcast (default: reply) | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 3 | *setMode = \&mode; # Mode: post or call (default: post) | |||||||||||||||||||||||||||||||
| 69 | 3 | *getMode = \&mode; # Mode: post or call (default: post) | |||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 72 | # Self routing messages without CODE refs, suitable for Filtering. | ||||||||||||||||||||||||||||||||
| 73 | # Keep first implementation simple (if you call allowing multiple | ||||||||||||||||||||||||||||||||
| 74 | # "RouteBack" destinations simple :-), and anticipate extensions. | ||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||
| 76 | # $message->header->addRouteBack( $mode, $service, $event, @args ); | ||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||
| 78 | # $mode defaults to "post", | ||||||||||||||||||||||||||||||||
| 79 | # $service defaults to "current_active", | ||||||||||||||||||||||||||||||||
| 80 | # and "initial state" @args are optionsl | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | # NOTE: these are LIFO stacks, and are "pushed" when "add" methods are | ||||||||||||||||||||||||||||||||
| 83 | # used and "popped" when "del" methods are used. See the "Message" | ||||||||||||||||||||||||||||||||
| 84 | # class for the various methods that make use of these stacks. | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | sub addRouteTo { shift->_addRouting( "RouteTo", undef, undef, @_ ) } | ||||||||||||||||||||||||||||||
|
Subroutine
addRouteTo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub addRouteBack { shift->_addRouting( "RouteBack", undef, undef, @_ ) } | ||||||||||||||||||||||||||||||
|
Subroutine
addRouteBack: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | sub addRemoteRouteTo { shift->_addRouting( "RouteTo", @_ ) } | ||||||||||||||||||||||||||||||
|
Subroutine
addRemoteRouteTo: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub addRemoteRouteBack { shift->_addRouting( "RouteBack", @_ ) } | ||||||||||||||||||||||||||||||
|
Subroutine
addRemoteRouteBack: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | sub _addRouting | ||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | { my($self, $type, $host, $port, $mode, $service, $event, @args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_addRouting: called CC=14 SCAR=32.8
| |||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 4 | ▶ | if ($type !~ /^Route(To|Back)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 95 | 0 | return $self->setErr(-1, "unknown 'type' ($type) in 'addRouting' method of '$PACK'"); | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | $host ||= ""; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$host ||= ""
MC/DC100%1/1
$host ||= ""
$host
Truth table100%2/2
A
A= $host
| |||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | $port ||= ""; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$port ||= ""
MC/DC100%1/1
$port ||= ""
$port
Truth table100%2/2
A
A= $port
| |||||||||||||||||||||||||||||||||
| 101 | # $mode ||= "post"; | ||||||||||||||||||||||||||||||||
| 102 | 4 | ▶ | ( $mode = $self->mode() || "post" ) unless ( $mode ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->mode || 'post'
MC/DC0%0/1
$self->mode || 'post'
$self->mode
Truth table0%0/2
A
A= $self->mode
| |||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 4 | ▶ | if ($host and $port) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$host and $port
MC/DC50%1/2
$host and $port
$host
$port
Truth table66%2/3
A and B
A= $hostB= $port
| |||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | $service ||= "command"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$service ||= "command"
MC/DC0%0/1
$service ||= "command"
$service
Truth table50%1/2
A
A= $service
| |||||||||||||||||||||||||||||||||
| 106 | 2 | ▶ | $event ||= "dispatch"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$event ||= "dispatch"
MC/DC0%0/1
$event ||= "dispatch"
$event
Truth table50%1/2
A
A= $event
| |||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | } elsif (! $service ) { | ||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if (! defined $INC{'POE/Kernel.pm'}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | 0 | return $self->setErr(-1, "'POE::Kernel' module is not loaded in 'addRouteBack' method of '$PACK'"); | |||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | } else { | ||||||||||||||||||||||||||||||||
| 113 | 0 | $service = POE::Kernel->get_active_session()->ID(); | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | ## warn "DEBUG: _addRouting: type='$type' mode='$mode' service='$service' event='$event'\n"; | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 4 | ▶ | if (! ($service and $event) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$service and $event
MC/DC0%0/2
$service and $event
$service
$event
Truth table33%1/3
A and B
A= $serviceB= $event
| |||||||||||||||||||||||||||||||||
| 120 | 0 | return $self->setErr(-1, "missing 'service' and/or 'event' argument in 'addRouting' method of '$PACK'"); | |||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 4 | unshift @{ $self->{$type} }, [ $host,$port, $mode,$service,$event,@args ]; | |||||||||||||||||||||||||||||||
| 124 | 4 | return; | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 3 | *unshiftRouteTo = \&addRouteTo; # add a RouteTo | |||||||||||||||||||||||||||||||
| 128 | 3 | *shiftRouteTo = \&delRouteTo; # del a RouteTo | |||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 3 | *unshiftRouteBack = \&addRouteBack; # add a RouteBack | |||||||||||||||||||||||||||||||
| 131 | 3 | *shiftRouteBack = \&delRouteBack; # del a Routeback | |||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | # FIX: syntax for "delRoute*" is clumsy when the lists are empty. | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | sub delRouteTo { @{ (shift @{ $_[0]->{RouteTo} } ||[]) } } | ||||||||||||||||||||||||||||||
|
Subroutine
delRouteTo: called CC=2 SCAR=7.1
Pod
undocumented
Condition50%1/2
shift @{$_[0]{'RouteTo'};} || []
MC/DC0%0/1
shift @{$_[0]{'RouteTo'};} || []
shift @{$_[0]{'RouteTo'};}
Truth table50%1/2
A
A= shift @{$_[0]{'RouteTo'};}
| |||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | sub delRouteBack { @{ (shift @{ $_[0]->{RouteBack} } ||[]) } } | ||||||||||||||||||||||||||||||
|
Subroutine
delRouteBack: called CC=2 SCAR=7.1
Pod
undocumented
Condition50%1/2
shift @{$_[0]{'RouteBack'};} || []
MC/DC0%0/1
shift @{$_[0]{'RouteBack'};} || []
shift @{$_[0]{'RouteBack'};}
Truth table50%1/2
A
A= shift @{$_[0]{'RouteBack'};}
| |||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | sub hasRouting { ( ($_[0]->hasRouteTo()) || ($_[0]->hasRouteBack()) ) } | ||||||||||||||||||||||||||||||
|
Subroutine
hasRouting: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 3 | *getRouting = \&hasRouting; | |||||||||||||||||||||||||||||||
| 141 | 3 | *getRouteTo = \&hasRouteTo; | |||||||||||||||||||||||||||||||
| 142 | 3 | *getRouteBack = \&hasRouteBack; | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | sub hasRouteTo | ||||||||||||||||||||||||||||||||
| 145 | 11 | ▶ | { my($self, $type) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
hasRouteTo: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 146 | 11 | ▶ | return undef unless (defined $self->{"RouteTo"}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 147 | 11 | return( $self->{'RouteTo'}->[ 0 ] ); | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | sub hasRouteBack | ||||||||||||||||||||||||||||||||
| 151 | 3 | ▶ | { my($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
hasRouteBack: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 152 | 3 | ▶ | return undef unless (defined $self->{"RouteBack"}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 153 | 3 | return( $self->{'RouteBack'}->[ 0 ] ); | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | sub nextRouteType | ||||||||||||||||||||||||||||||||
| 157 | 8 | ▶ | { my($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
nextRouteType: called CC=7 SCAR=23.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 8 | ▶ | my $nextRoute = $self->hasRouteTo() || $self->hasRouteBack(); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->hasRouteTo || $self->hasRouteBack
MC/DC0%0/2
$self->hasRouteTo || $self->hasRouteBack
$self->hasRouteTo
$self->hasRouteBack
Truth table33%1/3
A || B
A= $self->hasRouteToB= $self->hasRouteBack
| |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 8 | ▶ | return "remote" if ($nextRoute->[0] and $nextRoute->[1]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nextRoute->[0] and $nextRoute->[1]
MC/DC50%1/2
$nextRoute->[0] and $nextRoute->[1]
$nextRoute->[0]
$nextRoute->[1]
Truth table66%2/3
A and B
A= $nextRoute->[0]B= $nextRoute->[1]
| |||||||||||||||||||||||||||||||||
| 162 | 4 | ▶ | return "" unless $nextRoute->[2]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 4 | ▶ | return "post" if ($nextRoute->[2] =~ /^post/i); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return "call" if ($nextRoute->[2] =~ /^call/i); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | 0 | return ""; | |||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | sub nextRouteIsRemote { ($_[0]->nextRouteType() eq "remote" ? 1 : 0) } | ||||||||||||||||||||||||||||||
|
Subroutine
nextRouteIsRemote: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | sub nextRouteIsLocal { ($_[0]->nextRouteType() =~ /(post|call)/ ? 1 : 0) } | ||||||||||||||||||||||||||||||
|
Subroutine
nextRouteIsLocal: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | sub nextRouteIsPost { ($_[0]->nextRouteType() eq "post" ? 1 : 0) } | ||||||||||||||||||||||||||||||
|
Subroutine
nextRouteIsPost: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | sub nextRouteIsCall { ($_[0]->nextRouteType() eq "call" ? 1 : 0) } | ||||||||||||||||||||||||||||||
|
Subroutine
nextRouteIsCall: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 176 | 0 | my($self,$nohead)= @_; | |||||||||||||||||||||||||||||||
| 177 | 0 | my($pack,$file,$line)=caller(); | |||||||||||||||||||||||||||||||
| 178 | 0 | my $text = ""; | |||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | unless ($nohead) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | 0 | $text .= "DEBUG: ($PACK\:\:dump)\n self='$self'\n"; | |||||||||||||||||||||||||||||||
| 181 | 0 | $text .= "CALLER $pack at line $line\n ($file)\n"; | |||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | 0 | my $value; | |||||||||||||||||||||||||||||||
| 184 | 0 | foreach my $param (sort keys %$self) { | |||||||||||||||||||||||||||||||
| 185 | 0 | $value = $self->{$param}; | |||||||||||||||||||||||||||||||
| 186 | 0 | $value = $self->zeroStr( $value, "" ); # handles value of "0" | |||||||||||||||||||||||||||||||
| 187 | 0 | $text .= " $param = $value\n"; | |||||||||||||||||||||||||||||||
| 188 | # Kinda kludgy, might wanna fix this next bit. | ||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($param =~ /^Route(To|Back)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my $arrow = ( $param eq "RouteTo" ? "-->" : "<--" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if (! @$value) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | 0 | $text .= " $arrow ((empty list))\n"; | |||||||||||||||||||||||||||||||
| 193 | 0 | next; | |||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||
| 195 | 0 | foreach my $route (@$value) { | |||||||||||||||||||||||||||||||
| 196 | 0 | $text .= " $arrow '"; | |||||||||||||||||||||||||||||||
| 197 | 0 | foreach my $arg (@$route) { | |||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $text .= ( $arg ? "$arg', '" : "', '" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | 0 | chop($text); chop($text); chop($text); | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | 0 | $text .= "\n" | |||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||
| 205 | 0 | $text .= "_" x 25 ."\n"; | |||||||||||||||||||||||||||||||
| 206 | 0 | return($text); | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | sub zeroStr | ||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | { my($self,$value,$undef) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
zeroStr: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return $undef unless defined $value; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return "0" if (length($value) and ! $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $value and not $value
MC/DC0%0/2
length $value and not $value
length $value
not $value
Truth table0%0/3
A and not(B)
A= length $valueB= not $value
| |||||||||||||||||||||||||||||||||
| 213 | 0 | return $value; | |||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||
| 215 | #_________________________ | ||||||||||||||||||||||||||||||||
| 216 | 3 | 1; # Required by require() | |||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | __END__ | ||||||||||||||||||||||||||||||||