line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hub::Knots::Object; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
3
|
1
|
|
|
1
|
|
6
|
use Hub qw/:lib/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
our $VERSION = '4.00043'; |
5
|
|
|
|
|
|
|
our @EXPORT = qw//; |
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
9
|
|
|
|
|
|
|
# _access - Direct access to members |
10
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _access { |
13
|
0
|
|
|
0
|
|
|
my $self = shift; |
14
|
0
|
|
|
|
|
|
my $index = shift; |
15
|
0
|
|
|
|
|
|
return $self->{$index}; |
16
|
|
|
|
|
|
|
}#_access |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
19
|
|
|
|
|
|
|
# _keyname - Determine which key (public or private) to use |
20
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _keyname { |
23
|
0
|
|
|
0
|
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my $index = shift; |
25
|
0
|
0
|
0
|
|
|
|
my $datakey = defined $index && |
26
|
|
|
|
|
|
|
$$index =~ s/^(internal|public|private):// ? $1 : (); |
27
|
0
|
|
|
|
|
|
my $called_from = caller(1); |
28
|
0
|
0
|
0
|
|
|
|
$datakey ||= $self->{'internal'}{'impl'}->isa($called_from) ? 'private' : 'public'; |
29
|
0
|
|
|
|
|
|
return $datakey; |
30
|
|
|
|
|
|
|
}#_keyname |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
33
|
|
|
|
|
|
|
# TIEHASH - Tie interface method |
34
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub TIEHASH { |
37
|
0
|
|
|
0
|
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my $impl = shift; |
39
|
0
|
|
|
|
|
|
my $obj = bless { |
40
|
|
|
|
|
|
|
'internal' => { impl => $impl }, # neither public or private |
41
|
|
|
|
|
|
|
'public' => {}, |
42
|
|
|
|
|
|
|
'private' => {}, |
43
|
|
|
|
|
|
|
}, $self; |
44
|
0
|
|
|
|
|
|
return $obj; |
45
|
|
|
|
|
|
|
}#TIEHASH |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
48
|
|
|
|
|
|
|
# FETCH - Tie interface method |
49
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub FETCH { |
52
|
0
|
|
|
0
|
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
my $index = shift; |
54
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname( \$index ); |
55
|
0
|
0
|
|
|
|
|
return $index ? $self->{$datakey}->{$index} : $self->{$datakey}; |
56
|
|
|
|
|
|
|
}#FETCH |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
59
|
|
|
|
|
|
|
# STORE - Tie interface method |
60
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub STORE { |
63
|
0
|
|
|
0
|
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my $index = shift; |
65
|
0
|
|
|
|
|
|
my $value = shift; |
66
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname( \$index ); |
67
|
0
|
0
|
|
|
|
|
$index ? $self->{$datakey}->{$index} = $value : $self->{$datakey} = $value; |
68
|
|
|
|
|
|
|
}#STORE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
71
|
|
|
|
|
|
|
# DELETE - Tie interface method |
72
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub DELETE { |
75
|
0
|
|
|
0
|
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $index = shift; |
77
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname( \$index ); |
78
|
0
|
|
|
|
|
|
delete $self->{$datakey}->{$index}; |
79
|
|
|
|
|
|
|
}#DELETE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
82
|
|
|
|
|
|
|
# CLEAR - Tie interface method |
83
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub CLEAR { |
86
|
0
|
|
|
0
|
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname(); |
88
|
0
|
|
|
|
|
|
my @reset = keys %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
map { delete $self->{$datakey}->{$_} } keys %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
}#CLEAR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
93
|
|
|
|
|
|
|
# EXISTS - Tie interface method |
94
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub EXISTS { |
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
my $index = shift; |
99
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname( \$index ); |
100
|
0
|
|
|
|
|
|
exists $self->{$datakey}->{$index}; |
101
|
|
|
|
|
|
|
}#EXISTS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
104
|
|
|
|
|
|
|
# FIRSTKEY - Tie interface method |
105
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub FIRSTKEY { |
108
|
0
|
|
|
0
|
|
|
my $self = shift; |
109
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname(); |
110
|
0
|
|
|
|
|
|
my @reset = keys %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
each %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
}#FIRSTKEY |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
115
|
|
|
|
|
|
|
# NEXTKEY - Tie interface method |
116
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub NEXTKEY { |
119
|
0
|
|
|
0
|
|
|
my $self = shift; |
120
|
0
|
|
|
|
|
|
my $lastindex = shift; |
121
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname(); |
122
|
0
|
|
|
|
|
|
each %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
}#NEXTKEY |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
126
|
|
|
|
|
|
|
# SCALAR - Tie interface method |
127
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub SCALAR { |
130
|
0
|
|
|
0
|
|
|
my $self = shift; |
131
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname(); |
132
|
0
|
|
|
|
|
|
scalar %{$self->{$datakey}}; |
|
0
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
}#SCALAR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
136
|
|
|
|
|
|
|
# UNTIE - Tie interface method |
137
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub UNTIE { |
140
|
0
|
|
|
0
|
|
|
my $self = shift; |
141
|
0
|
|
0
|
|
|
|
my $count = shift || 0; |
142
|
0
|
|
|
|
|
|
my $datakey = $self->_keyname(); |
143
|
|
|
|
|
|
|
}#UNTIE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |