line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hub::Knots::TiedObject; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
6
|
use Hub qw/:lib/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '4.00043'; |
5
|
|
|
|
|
|
|
our @EXPORT = qw//; |
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
9
|
|
|
|
|
|
|
# _key - Determine which key (public or private) to use |
10
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _key { |
13
|
366
|
|
|
366
|
|
505
|
my $index = shift; |
14
|
366
|
|
|
|
|
600
|
local $1; |
15
|
366
|
100
|
|
|
|
1627
|
return $index =~ /^\*(.*)/ ? ('private',$1) : ('public',$index); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
19
|
|
|
|
|
|
|
# TIEHASH - Tie interface method |
20
|
|
|
|
|
|
|
# TIEHASH 'Hub::Knots::TiedObject', $PACKAGE |
21
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub TIEHASH { |
24
|
17
|
|
|
17
|
|
33
|
my $self = shift; |
25
|
17
|
|
|
|
|
30
|
my $pkg_name = shift; |
26
|
17
|
|
|
|
|
34
|
my %data = (); |
27
|
17
|
|
|
|
|
95
|
my $obj = bless { |
28
|
|
|
|
|
|
|
'public' => \%data, |
29
|
|
|
|
|
|
|
'private' => { |
30
|
|
|
|
|
|
|
'tied' => tie(%data, $pkg_name), |
31
|
|
|
|
|
|
|
'public' => \%data, |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
}, $self; |
34
|
17
|
|
|
|
|
62
|
return $obj; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
38
|
|
|
|
|
|
|
# FETCH - Return a value |
39
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub FETCH { |
42
|
216
|
|
|
216
|
|
263
|
my $self = shift; |
43
|
216
|
|
|
|
|
283
|
my $index = shift; |
44
|
216
|
|
|
|
|
355
|
my ($namespace,$key) = _key($index); |
45
|
216
|
|
|
|
|
2799
|
return $self->{$namespace}->{$key}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
49
|
|
|
|
|
|
|
# STORE - Store a value |
50
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub STORE { |
53
|
146
|
|
|
146
|
|
1255
|
my $self = shift; |
54
|
146
|
|
|
|
|
172
|
my $index = shift; |
55
|
146
|
|
|
|
|
168
|
my $value = shift; |
56
|
146
|
|
|
|
|
237
|
my ($namespace,$key) = _key($index); |
57
|
146
|
|
|
|
|
733
|
$self->{$namespace}->{$key} = $value; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
# DELETE - Remove a value |
62
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub DELETE { |
65
|
4
|
|
|
4
|
|
20
|
my $self = shift; |
66
|
4
|
|
|
|
|
6
|
my $index = shift; |
67
|
4
|
|
|
|
|
8
|
my ($namespace,$key) = _key($index); |
68
|
4
|
|
|
|
|
23
|
delete $self->{$namespace}->{$key}; |
69
|
|
|
|
|
|
|
}#DELETE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
72
|
|
|
|
|
|
|
# CLEAR - Remove all public values |
73
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub CLEAR { |
76
|
0
|
|
|
0
|
|
0
|
$_[0]->{'private'}{'tied'}->CLEAR(@_); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
80
|
|
|
|
|
|
|
# EXISTS - Boolean test for value |
81
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub EXISTS { |
84
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
85
|
0
|
|
|
|
|
0
|
my $index = shift; |
86
|
0
|
|
|
|
|
0
|
my ($namespace,$key) = _key($index); |
87
|
0
|
|
|
|
|
0
|
exists $self->{$namespace}->{$key}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
91
|
|
|
|
|
|
|
# FIRSTKEY - Tie interface method |
92
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub FIRSTKEY { |
95
|
16
|
|
|
16
|
|
99
|
$_[0]->{'private'}{'tied'}->FIRSTKEY(@_); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
99
|
|
|
|
|
|
|
# NEXTKEY - Tie interface method |
100
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub NEXTKEY { |
103
|
75
|
|
|
75
|
|
262
|
$_[0]->{'private'}{'tied'}->NEXTKEY(@_); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
107
|
|
|
|
|
|
|
# SCALAR - Scalar representation |
108
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub SCALAR { |
111
|
0
|
|
|
0
|
|
|
$_[0]->{'private'}{'tied'}->SCALAR(@_); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
115
|
|
|
|
|
|
|
# UNTIE - Tie interface method |
116
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub UNTIE { |
119
|
0
|
|
|
0
|
|
|
my $self = shift; |
120
|
0
|
|
0
|
|
|
|
my $count = shift || 0; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |