| 1 | package Config::apiLayers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 1 | ▶ | use Symbol qw{ qualify_to_ref }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use vars qw($VERSION $LASTMOD $DEBUG $CXLCFG $CXLDATA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | $LASTMOD = 20160329; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $CXLCFG = '_cxl_cfg'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | $CXLDATA = '_cxl_data'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | sub _api_factory ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api_factory: called CC=3 SCAR=11.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | my $apiname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | my $validator = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | my $f_validator = sub ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $validator = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | if (!defined $validator) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | elsif (ref $validator eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | return $validator->($self,$name,$value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | elsif (!ref $validator) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return $value if $value =~ /$validator/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # The method for setting/getting the attribute's value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | warn "Creating Getter/Setter for $apiname called.\n" if $self->{'DEBUG'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | my $name = $apiname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | warn "Getter/Setter for $name called.\n" if $self->{'DEBUG'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | my $value = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || undef
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if (my $valid = $f_validator->($self,$name,$validator,$value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | #return $self->config({ 'data' => { $name => $valid } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $self->config({ 'data' => { $name => $valid } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # In the future, we'll do more here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | my $paramedic = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | if (ref $value eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | return $value->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | foreach my $layer (reverse @{$self->{$CXLDATA}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | ▶ | if (exists $layer->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | return $paramedic->($layer->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | sub _api_define ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api_define: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | my $apiname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | my $function = shift || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return undef)
MC/DC0%0/1
shift() || (return undef)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Qualifying symbols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # This does not work in Perl 5.12 and lower | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | #my $ref = *{ Symbol::qualify_to_ref( $apiname ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | #*{ $ref } = $function; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # This is verified to work in at least Perl 5.10.1 through 5.16.3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | #*{ Symbol::qualify_to_ref( $apiname ) } = $function; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | my $ref = Symbol::qualify_to_ref( $apiname ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | *{ $ref } = $function; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub _api_undefine ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api_undefine: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $apiname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $ref = *{ Symbol::qualify_to_ref( $apiname ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | *{ $ref } = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # @attributes = [ a, b, c ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # @attributes = [ { a => v1, b => v2, c => v3 } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # @attributes = [ { name => 'length', validator => \&func, getoptlong => 'length|l:i', description => 'long description' } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # @autoproto = 1|0 ; default is 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub new (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=25.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | my $class = ref($pkg) || $pkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $pkg || $pkg
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg
$pkg
Truth table33%1/3
A || B
A= ref $pkgB= $pkg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | my $self = bless {},$class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | my $autoproto = $args->{'autoproto'} || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'autoproto'} || 1
MC/DC0%0/1
$args->{'autoproto'} || 1
$args->{'autoproto'}
Truth table50%1/2
A
A= $args->{'autoproto'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | my $attr_add = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | my $attr_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | my $validator = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | my $getoptlong = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || undef
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | my $description = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || undef
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | push (@{$self->{$CXLCFG}->{'attributes'}}, $attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | $self->{$CXLCFG}->{'validators'}->{$attr_name} = $validator if defined $validator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | $self->{$CXLCFG}->{'getoptlong'}->{$attr_name} = $getoptlong if defined $getoptlong; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | $self->{$CXLCFG}->{'description'}->{$attr_name} = $description if defined $description; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | my $attr_func = $self->_api_factory($attr_name,$validator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | warn "ERROR in creating function for $attr_name\n" if !defined $attr_func; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | $self->{$CXLCFG}->{'api'}->{$attr_name} = $attr_func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | ▶ | if ($autoproto == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | $self->_api_define($attr_name,$attr_func); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | ▶ | my $attr_add_hash = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | my $attr_hash = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | if (exists $attr_hash->{'name'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | my $name = $attr_hash->{'name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | my $validator = $attr_hash->{'validator'} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attr_hash->{'validator'} || undef
MC/DC0%0/1
$attr_hash->{'validator'} || undef
$attr_hash->{'validator'}
Truth table50%1/2
A
A= $attr_hash->{'validator'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | my $getoptlong = $attr_hash->{'getoptlong'} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$attr_hash->{'getoptlong'} || undef
MC/DC100%1/1
$attr_hash->{'getoptlong'} || undef
$attr_hash->{'getoptlong'}
Truth table100%2/2
A
A= $attr_hash->{'getoptlong'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | ▶ | my $description = $attr_hash->{'description'} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$attr_hash->{'description'} || undef
MC/DC100%1/1
$attr_hash->{'description'} || undef
$attr_hash->{'description'}
Truth table100%2/2
A
A= $attr_hash->{'description'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | $attr_add->($name, $validator, $getoptlong, $description); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | foreach my $attr (keys %{$attr_hash}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $attr_add->($attr, $attr_hash->{$attr}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | if ((exists $args->{'attributes'}) && (ref $args->{'attributes'} eq "ARRAY")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
exists $args->{"attributes"} and ref $args->{"attributes"} eq "ARRAY"
MC/DC0%0/2
exists $args->{"attributes"} and ref $args->{"attributes"} eq "ARRAY"
exists $args->{"attributes"}
ref $args->{"attributes"} eq "ARRAY"
Truth table33%1/3
A and B
A= exists $args->{"attributes"}B= ref $args->{"attributes"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | foreach my $attr (@{$args->{'attributes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | ▶ | if (ref $attr eq "HASH") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | $attr_add_hash->($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $attr_add->($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ▶ | } elsif ((exists $args->{'attributes'}) && (ref $args->{'attributes'} eq "HASH")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $args->{"attributes"} and ref $args->{"attributes"} eq "HASH"
MC/DC0%0/2
exists $args->{"attributes"} and ref $args->{"attributes"} eq "HASH"
exists $args->{"attributes"}
ref $args->{"attributes"} eq "HASH"
Truth table0%0/3
A and B
A= exists $args->{"attributes"}B= ref $args->{"attributes"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | foreach my $attr_name (keys %{$args->{'attributes'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $attr_add_hash->($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Set or retrieve a configuration layer, without validation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Set with @index and @data, or jusr @data for the last existing index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Retrieve with only @index, or without index retrieve the last existing index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # @data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # @index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | sub config ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=8 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | ▶ | my $lastLayer = ref $self->{$CXLDATA} eq "ARRAY" ? (scalar @{$self->{$CXLDATA}} - 1) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | my $layer_idx = exists $args->{'index'} ? $args->{'index'} : $lastLayer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | if (! exists $args->{'data'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (defined $self->{$CXLDATA}->[$layer_idx]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return $self->{$CXLDATA}->[$layer_idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | my $config = $args->{'data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | my $attrs = $self->{$CXLCFG}->{'attributes'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | foreach my $key (keys %{$config}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | ▶ | next unless grep {/^$key$/} @{$attrs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | $self->{$CXLDATA}->[$layer_idx]->{$key} = $config->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # Import the data, performing validation as available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # @data - the data to import | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | sub importdata ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
importdata: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $attrs = $self->{$CXLCFG}->{'attributes'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if (exists $args->{'data'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | foreach my $key (keys %{$args->{'data'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | next unless grep {/^$key$/} @{$attrs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | unless ($self->apicall($key,$args->{'data'}->{$key})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | return 0 if $errors >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Export the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # @cfg - getoptlong|descriptions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # @data - undef|layerNumber|[startingLayer,endingLayer] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | ▶ | sub exportdata ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exportdata: called CC=21 SCAR=31.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | my $attrs = $self->{$CXLCFG}->{'attributes'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | if ((exists $args->{'cfg'}) && ($args->{'cfg'} eq "getoptlong")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
exists $args->{"cfg"} and $args->{"cfg"} eq "getoptlong"
MC/DC100%2/2
exists $args->{"cfg"} and $args->{"cfg"} eq "getoptlong"
exists $args->{"cfg"}
$args->{"cfg"} eq "getoptlong"
Truth table100%3/3
A and B
A= exists $args->{"cfg"}B= $args->{"cfg"} eq "getoptlong"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $getoptlong = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | foreach my $attr_name (@{$attrs}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | ▶ | next unless defined $self->{$CXLCFG}->{'getoptlong'}->{$attr_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | push (@{$getoptlong}, $self->{$CXLCFG}->{'getoptlong'}->{$attr_name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | return $getoptlong; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ▶ | } elsif ((exists $args->{'cfg'}) && ($args->{'cfg'} eq "descriptions")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $args->{"cfg"} and $args->{"cfg"} eq "descriptions"
MC/DC50%1/2
exists $args->{"cfg"} and $args->{"cfg"} eq "descriptions"
exists $args->{"cfg"}
$args->{"cfg"} eq "descriptions"
Truth table66%2/3
A and B
A= exists $args->{"cfg"}B= $args->{"cfg"} eq "descriptions"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | my $description = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | foreach my $attr_name (@{$attrs}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | ▶ | next unless defined $self->{$CXLCFG}->{'description'}->{$attr_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | push (@{$description}, $attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | push (@{$description}, $self->{$CXLCFG}->{'description'}->{$attr_name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | return $description; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } elsif (exists $args->{'data'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | my $firstLayer = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | my $lastLayer = (scalar @{$self->{$CXLDATA}} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | if ( (defined $args->{'data'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%6/9
defined $args->{"data"} and not ref $args->{"data"} and $args->{"data"} >= $firstLayer and $args->{"data"} <= $lastLayer
defined $args->{"data"} and not ref $args->{"data"} and $args->{"data"} >= $firstLayer
defined $args->{"data"} and not ref $args->{"data"}
MC/DC25%1/4
defined $args->{"data"} and not ref $args->{"data"} and $args->{"data"} >= $firstLayer and $args->{"data"} <= $lastLayer
defined $args->{"data"}
not ref $args->{"data"}
$args->{"data"} >= $firstLayer
$args->{"data"} <= $lastLayer
Truth table40%2/5
A and not(B) and C and D
A= defined $args->{"data"}B= not ref $args->{"data"}C= $args->{"data"} >= $firstLayerD= $args->{"data"} <= $lastLayer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | && (!ref $args->{'data'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | && ($args->{'data'} >= $firstLayer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | && ($args->{'data'} <= $lastLayer)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | return $self->{$CXLDATA}->[$args->{'data'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } elsif (ref $args->{'data'} eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | ▶ | $firstLayer = shift @{$args->{'data'}} || $firstLayer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift @{$$args{'data'};} || $firstLayer
MC/DC0%0/2
shift @{$$args{'data'};} || $firstLayer
shift @{$$args{'data'};}
$firstLayer
Truth table33%1/3
A || B
A= shift @{$$args{'data'};}B= $firstLayer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | $lastLayer = pop @{$args->{'data'}} || $lastLayer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
pop @{$$args{'data'};} || $lastLayer
MC/DC0%0/2
pop @{$$args{'data'};} || $lastLayer
pop @{$$args{'data'};}
$lastLayer
Truth table33%1/3
A || B
A= pop @{$$args{'data'};}B= $lastLayer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | my $export = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | foreach my $key (@{$attrs}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | for ($firstLayer..$lastLayer) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | my $layer_idx = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 6 | ▶ | next unless exists $self->{$CXLDATA}->[$layer_idx]->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | $export->{$key} = $self->{$CXLDATA}->[$layer_idx]->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | return $export if keys %{$export}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Add layers up to the given index, with or without data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Add a layer with @index and @data, or just @index, or add one more layer without @index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # Add more than one layer by providing the appropriate @index layer number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # The @data is only set into the last layer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # @index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # @data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | sub add_layer($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_layer: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | ▶ | if (ref $self->{$CXLDATA} ne "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->{$CXLDATA} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | my $nextLayer = scalar @{$self->{$CXLDATA}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | my $layerNumber = exists $args->{'index'} ? $args->{'index'} : $nextLayer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | for ($nextLayer..$layerNumber) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | push( @{$self->{$CXLDATA}}, {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | ▶ | if (exists $args->{'data'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | $self->config({ data => $args->{'data'} , index => $layerNumber }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | return (scalar @{$self->{$CXLDATA}} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | ▶ | sub apican(;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apican: called CC=5 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | ▶ | my $attr_name = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | ▶ | if (defined $attr_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | ▶ | return $self->{$CXLCFG}->{'api'}->{$attr_name} if exists $self->{$CXLCFG}->{'api'}->{$attr_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | return wantarray ? @{$self->{$CXLCFG}->{'attributes'}} : $self->{$CXLCFG}->{'attributes'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | ▶ | sub apicall(;$){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apicall: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | my $attr_name = shift || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return undef)
MC/DC0%0/1
shift() || (return undef)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | if (defined $attr_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | my $subref = $self->apican($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | unshift(@_,$self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | #goto &$subref if defined $subref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | ▶ | $subref->(@_) if defined $subref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # Non-Object helper functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # To be used inside the api functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub _mendPath(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mendPath: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my @path = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | foreach my $p (@path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | next unless defined $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ($path =~ /.+\/$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | chop($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | while ($p =~ /.+\/\/$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | chop($p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if (!defined $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $path = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $path = ($path.'/'.$p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # _mendLastRootPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Given an array of items that may define one or more paths from root '/' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # return the last grouping of items that define one path from root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # ex: _mendLastRootPath(qw( /path to file /next path to dir)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # returns: '/next/path/to/dir' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # This is handy when the users input for a parameter can either be a full path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # from root, or a subpath of another parameter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # In this case, this would be the resulting example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # # when $homedir = /home | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # # and $userhomedir = ( jsmith | /home/jsmith ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # my $path = mendlastrootpath( $homedir, $userhomedir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # # $path eq '/home/jsmith' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub _mendLastRootPath (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mendLastRootPath: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my @rootitems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | foreach my $item (@items) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ($item =~ /^\//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | @rootitems = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | push (@rootitems,$item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | push (@rootitems,$item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | return $self->mendPath(@rootitems); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub _dirFileSplit($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dirFileSplit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if (-d $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return ($path,undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ($baseDir,$fileName) = $path =~ /^(.*\/)([^\/]*)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return @{[$baseDir,$fileName]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub _dirBase($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dirBase: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my ($baseDir,$fileName) = _DirFileSplit($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $baseDir = './' unless defined $baseDir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return $baseDir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub _fileName($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fileName: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my ($baseDir,$fileName) = _DirFileSplit($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||