line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2012, Broadcom Corporation. All rights reserved. |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This file is part of the DMTF::CIM module. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DMTF::CIM::_model; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
our $VERSION = qv('0.04'); |
12
|
1
|
|
|
1
|
|
63
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
846
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Module implementation here |
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
0
|
|
my $self={}; |
18
|
0
|
|
|
|
|
|
$self->{CLASS}=shift; |
19
|
0
|
|
|
|
|
|
$self->{PARENT}=shift; |
20
|
0
|
|
0
|
|
|
|
$self->{DATA}=shift || {}; |
21
|
0
|
|
|
|
|
|
bless($self, $self->{CLASS}); |
22
|
0
|
|
|
|
|
|
return($self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parent |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
28
|
0
|
|
|
|
|
|
return $self->{PARENT}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Read-only |
32
|
|
|
|
|
|
|
sub name |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
35
|
0
|
|
|
|
|
|
return $self->{DATA}{name}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Read-only |
39
|
|
|
|
|
|
|
sub qualifier |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
42
|
0
|
|
|
|
|
|
my $name=shift; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if(!defined $name) { |
45
|
0
|
|
|
|
|
|
carp("No qualifier name specified"); |
46
|
0
|
|
|
|
|
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
return unless defined $self->{DATA}{qualifiers}; |
50
|
0
|
0
|
|
|
|
|
return unless defined $self->{DATA}{qualifiers}{lc($name)}; |
51
|
0
|
|
|
|
|
|
return $self->{DATA}{qualifiers}{lc($name)}{value}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Read-only |
55
|
|
|
|
|
|
|
sub is_array |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
0
|
|
|
|
if(defined $self->{DATA}{array} |
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|| ref(${$self->{VALUE}}) eq 'ARRAY') { |
61
|
|
|
|
|
|
|
# Anything in here is true... |
62
|
0
|
0
|
|
|
|
|
return '0 but true' unless defined $self->{VALUE}; |
63
|
0
|
0
|
|
|
|
|
return 1 unless ref(${$self->{VALUE}}) eq 'ARRAY'; |
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $len=$#{${$self->{VALUE}}}+1; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
return '0 but true' unless $len > 0; |
66
|
0
|
|
|
|
|
|
return $len; |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Read-only |
72
|
|
|
|
|
|
|
sub is_ref |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
75
|
0
|
|
|
|
|
|
my $prop=shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
0
|
|
|
|
return 1 if defined $self->{DATA}{is_ref} && $self->{DATA}{is_ref} eq 'true'; |
78
|
0
|
|
|
|
|
|
return 0; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Read-only |
82
|
|
|
|
|
|
|
sub type |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
85
|
0
|
|
|
|
|
|
my $ret; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
$ret=$self->{DATA}{type} if defined $self->{DATA}{type}; |
88
|
0
|
0
|
|
|
|
|
$ret='string' unless defined $ret; |
89
|
0
|
0
|
|
|
|
|
$ret .= '[]' if $self->is_array; |
90
|
0
|
|
|
|
|
|
return $ret; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub map_value |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
96
|
0
|
|
|
|
|
|
my $mapval=shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
if(!defined $mapval) { |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
0
|
|
|
|
|
if(ref($mapval) ne '') { |
102
|
0
|
|
|
|
|
|
carp("Reference $mapval passed where value expected"); |
103
|
0
|
|
|
|
|
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
0
|
|
|
|
if(defined $self->{DATA}{qualifiers} |
|
0
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
107
|
|
|
|
|
|
|
&& defined $self->{DATA}{qualifiers}{valuemap} |
108
|
|
|
|
|
|
|
&& defined $self->{DATA}{qualifiers}{valuemap}{value} |
109
|
0
|
|
|
|
|
|
&& $#{$self->{DATA}{qualifiers}{valuemap}{value}} > -1 |
110
|
|
|
|
|
|
|
&& defined $self->{DATA}{qualifiers}{values} |
111
|
|
|
|
|
|
|
&& defined $self->{DATA}{qualifiers}{values}{value} |
112
|
|
|
|
|
|
|
&& $#{$self->{DATA}{qualifiers}{values}{value}} > -1) { |
113
|
0
|
|
|
|
|
|
my $default; |
114
|
0
|
|
|
|
|
|
my $valarr=$self->{DATA}{qualifiers}{valuemap}{value}; |
115
|
0
|
|
|
|
|
|
my $value=$mapval; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$value += 0; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
for(my $i=0; $i<=$#{$valarr}; $i++) { |
|
0
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $val=$valarr->[$i]; |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if($val eq '..') { |
123
|
0
|
|
|
|
|
|
$default=\$self->{DATA}{qualifiers}{values}{value}[$i]; |
124
|
0
|
|
|
|
|
|
next; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
0
|
|
|
|
|
if($val =~ /([0-9]*)\.\.([0-9]*)/) { |
|
|
0
|
|
|
|
|
|
127
|
0
|
0
|
0
|
|
|
|
if((!defined $1 || $1 <= $value) && (!defined $2 || $2 >= $value)) { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $self->{DATA}{qualifiers}{values}{value}[$i]; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif($val == $value) { |
132
|
0
|
|
|
|
|
|
return $self->{DATA}{qualifiers}{values}{value}[$i]; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
0
|
|
|
|
|
|
return $default; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
0
|
|
|
|
|
|
return $mapval; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub unmap_value |
143
|
|
|
|
|
|
|
{ |
144
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
145
|
0
|
|
|
|
|
|
my $value=shift; |
146
|
0
|
|
|
|
|
|
my $match=$value; |
147
|
0
|
|
|
|
|
|
my $i; |
148
|
0
|
0
|
0
|
|
|
|
return $value unless defined $self->{DATA}{qualifiers}{valuemap} && defined $self->{DATA}{qualifiers}{valuemap}{value}; |
149
|
0
|
|
|
|
|
|
my $valarr=$self->{DATA}{qualifiers}{valuemap}{value}; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
for($i=0; $i<=$#{$valarr}; $i++) { |
|
0
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $val=$valarr->[$i]; |
153
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if($val =~ /\.\./) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
next; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
elsif($self->{DATA}{qualifiers}{values}{value}[$i] eq $value) { |
158
|
0
|
|
|
|
|
|
return $valarr->[$i]; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
elsif(lc($self->{DATA}{qualifiers}{values}{value}[$i]) eq lc($value)) { |
161
|
0
|
|
|
|
|
|
$match=$valarr->[$i]; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
0
|
|
|
|
|
|
return $match; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; # Magic true value required at end of module |