line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EO::Data; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
22883
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
220
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
943
|
use EO; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use NEXT; |
8
|
|
|
|
|
|
|
use Scalar::Util qw(weaken); |
9
|
|
|
|
|
|
|
use EO::Hash; |
10
|
|
|
|
|
|
|
#use EO::Locale; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.96; |
13
|
|
|
|
|
|
|
our @ISA = qw(EO); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
exception EO::Error::InvalidParameter; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
my $string = ''; |
20
|
|
|
|
|
|
|
if ($self->NEXT::init( @_ )) { |
21
|
|
|
|
|
|
|
$self->{e_data_content} = \$string; |
22
|
|
|
|
|
|
|
$self->{e_data_storage} = {}; |
23
|
|
|
|
|
|
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub length { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
return length( $self->content ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub locales { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
if (@_) { |
36
|
|
|
|
|
|
|
$self->{ e_data_locales} = shift; |
37
|
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
return $self->{ e_data_locales }; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub locale { |
43
|
|
|
|
|
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
if (@_) { |
45
|
|
|
|
|
|
|
$self->{ e_data_locale } = shift; |
46
|
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
return $self->{ e_data_locale }; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub delete_storage { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
my $storage = shift; |
54
|
|
|
|
|
|
|
if (!UNIVERSAL::isa($storage, 'EO::Storage')) { |
55
|
|
|
|
|
|
|
throw EO::Error::InvalidParameter |
56
|
|
|
|
|
|
|
text => 'storage must be an EO::Storage object'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
delete($self->{e_data_storage}->{$storage}); |
59
|
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_storage { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
my $storage = shift; |
66
|
|
|
|
|
|
|
if (!UNIVERSAL::isa($storage, 'EO::Storage')) { |
67
|
|
|
|
|
|
|
throw EO::Error::InvalidParameter |
68
|
|
|
|
|
|
|
text => 'storage must be an EO::Storage object'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
$self->{e_data_storage}->{$storage} = $storage; |
71
|
|
|
|
|
|
|
weaken($self->{e_data_storage}->{$storage}); |
72
|
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub storage { |
76
|
|
|
|
|
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
if(@_) { |
78
|
|
|
|
|
|
|
my $storage = shift; |
79
|
|
|
|
|
|
|
if (!UNIVERSAL::isa($storage, 'EO::Storage')) { |
80
|
|
|
|
|
|
|
throw EO::Error::InvalidParameter |
81
|
|
|
|
|
|
|
text => 'storage must be an EO::Storage object'; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
$self->{e_data_storage} = { $storage => $storage }; |
84
|
|
|
|
|
|
|
weaken( $self->{e_data_storage}->{ $storage } ); |
85
|
|
|
|
|
|
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
return values %{$self->{e_data_storage}}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub content { |
91
|
|
|
|
|
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
if(@_) { |
93
|
|
|
|
|
|
|
my $content = shift; |
94
|
|
|
|
|
|
|
if(ref($content) eq 'SCALAR') { |
95
|
|
|
|
|
|
|
$self->{e_data_content} = $content; |
96
|
|
|
|
|
|
|
} elsif(ref($content) && $content->isa('EO::Data')) { |
97
|
|
|
|
|
|
|
$self->content($content->content_ref); |
98
|
|
|
|
|
|
|
} else { |
99
|
|
|
|
|
|
|
${$self->{e_data_content}} = $content; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
return ${$self->{e_data_content}}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub save { |
107
|
|
|
|
|
|
|
my $self = shift; |
108
|
|
|
|
|
|
|
foreach my $storage (values %{$self->{e_data_storage}}) { |
109
|
|
|
|
|
|
|
$storage->save($self); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
return $self; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub content_ref { |
115
|
|
|
|
|
|
|
my $self = shift; |
116
|
|
|
|
|
|
|
return $self->{e_data_content}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |