SIAM/DeviceComponent.pm

filter: Statementstmt 61.5% 16 / 26 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 56.1% 23 / 41 CC 4 SCAR 16.7
CC
4
Cov
50%
attached_to
12.0
is_attached
6.0
BEGIN
1.0
CRAP 5.3
« SIAM.pm ↑ Summary SIAM/Driver/Simple.pm »
1 package SIAM::DeviceComponent;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base 'SIAM::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 =head1 NAME
10  
11 SIAM::DeviceComponent - Device Component object class
12  
13 =head1 SYNOPSIS
14  
15 =head1 METHODS
16  
17 =head2 is_attached
18  
19 Returns true if the device component is attached to another device
20 component within the same device.
21  
22 =cut
23  
24 sub is_attached
25 0 ▶{
Subroutine is_attached: not called CC=2 SCAR=17.9
Pod documented
26 0 my $self = shift;
27 0 ▶ return( $self->attr('siam.devc.is_attached') ? 1:0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->attr('siam.devc.is_attached') ? : 0 0 0
28 }
29  
30  
31 =head2 attached_to
32  
33 Returns a SIAM::DeviceComponent object to which this object is attached.
34  
35 =cut
36  
37 sub attached_to
38 0 ▶{
Subroutine attached_to: not called CC=3 SCAR=24.8
Pod documented
39 0 my $self = shift;
40 0 ▶ if( $self->is_attached() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_attached) 0 0 0
41 {
42 0 my $id = $self->attr('siam.devc.attached_to');
43 0 ▶ if( not defined($id) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 0 0
44 {
45 0 $self->error('siam.devc.attached_to is undefined in ' . $self->id);
46 0 return undef;
47 }
48 0 return $self->instantiate_object('SIAM::DeviceComponent', $id);
49 }
50  
51 0 return;
52 }
53  
54  
55  
56  
57
58 # mandatory attributes
59  
60 3 my $mandatory_attributes =
61 [ 'siam.devc.inventory_id',
62 'siam.devc.type',
63 'siam.devc.name',
64 'siam.devc.full_name',
65 'siam.devc.description' ];
66  
67 3 my $optional_attributes =
68 [ 'siam.devc.is_attached',
69 'siam.devc.attached_to' ];
70  
71 sub _mandatory_attributes
72 9 ▶{
Subroutine _mandatory_attributes: called CC=1 SCAR=0.0
73 9 return $mandatory_attributes;
74 }
75  
76  
77 sub _manifest_attributes
78 1 ▶{
Subroutine _manifest_attributes: called CC=1 SCAR=0.0
79 1 return [@{$mandatory_attributes}, @{$optional_attributes}];
80 }
81  
82  
83 3 1;
84  
85 # Local Variables:
86 # mode: cperl
87 # indent-tabs-mode: nil
88 # cperl-indent-level: 4
89 # cperl-continued-statement-offset: 4
90 # cperl-continued-brace-offset: -4
91 # cperl-brace-offset: 0
92 # cperl-label-offset: -2
93 # End:
« SIAM.pm ↑ Summary SIAM/Driver/Simple.pm »