File Coverage

blib/lib/SIAM/DeviceComponent.pm
Criterion Covered Total %
statement 13 23 56.5
branch 0 6 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 20 38 52.6


line stmt bran cond sub pod time code
1             package SIAM::DeviceComponent;
2              
3 2     2   11 use warnings;
  2         4  
  2         122  
4 2     2   10 use strict;
  2         4  
  2         56  
5              
6 2     2   11 use base 'SIAM::Object';
  2         3  
  2         870  
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             {
26 0     0 1 0 my $self = shift;
27 0 0       0 return( $self->attr('siam.devc.is_attached') ? 1: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             {
39 0     0 1 0 my $self = shift;
40 0 0       0 if( $self->is_attached() )
41             {
42 0         0 my $id = $self->attr('siam.devc.attached_to');
43 0 0       0 if( not defined($id) )
44             {
45 0         0 $self->error('siam.devc.attached_to is undefined in ' . $self->id);
46 0         0 return undef;
47             }
48 0         0 return $self->instantiate_object('SIAM::DeviceComponent', $id);
49             }
50              
51 0         0 return;
52             }
53              
54              
55              
56              
57            
58             # mandatory attributes
59              
60             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             my $optional_attributes =
68             [ 'siam.devc.is_attached',
69             'siam.devc.attached_to' ];
70              
71             sub _mandatory_attributes
72             {
73 9     9   26 return $mandatory_attributes;
74             }
75              
76              
77             sub _manifest_attributes
78             {
79 1     1   2 return [@{$mandatory_attributes}, @{$optional_attributes}];
  1         3  
  1         9  
80             }
81              
82              
83             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: