line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::Daemon::Action::Serializable; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
7651
|
use warnings; |
|
11
|
|
|
|
|
43
|
|
|
11
|
|
|
|
|
657
|
|
4
|
11
|
|
|
11
|
|
97
|
use strict; |
|
11
|
|
|
|
|
34
|
|
|
11
|
|
|
|
|
424
|
|
5
|
11
|
|
|
11
|
|
83
|
use Moose::Role 2.1604; |
|
11
|
|
|
|
|
417
|
|
|
11
|
|
|
|
|
110
|
|
6
|
11
|
|
|
11
|
|
83406
|
use Storable 2.51 qw(nstore); |
|
11
|
|
|
|
|
329
|
|
|
11
|
|
|
|
|
846
|
|
7
|
11
|
|
|
11
|
|
98
|
use Carp; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
3442
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.29'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=pod |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Siebel::Srvrmgr::Daemon::Action::Serializable - role for serializable subclasses of Siebel::Srvrmgr::Daemon::Action |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This class is a role, not a subclass of L<Siebel::Srvrmgr::Daemon::Action>. It is intended to be used by subclasses that |
19
|
|
|
|
|
|
|
needs serialization to the filesystem. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 dump_file |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This attribute is a string used to indicate in which file the data from the class using this role should be serialized into |
26
|
|
|
|
|
|
|
the OS filesystem. The string can be a complete path or just the filename. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has dump_file => ( |
31
|
|
|
|
|
|
|
isa => 'Str', |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
reader => 'get_dump_file', |
34
|
|
|
|
|
|
|
writer => 'set_dump_file' |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 get_dump_file |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns the string stored in the attribute C<dump_file>. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 set_dump_file |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Sets the attribute C<dump_file>. Expects a string as parameter. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 BUILD |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Right after object creation this method will process the C<params> attribute and retrieve the first index of the array reference |
52
|
|
|
|
|
|
|
to define the C<dump_file> attribute using the method C<set_dump_file>. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
If the C<params> attribute is an empty reference, the method wil raise an exception. If the value given is undefined or an empty |
55
|
|
|
|
|
|
|
string, an exception will be raised as well. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub BUILD { |
60
|
|
|
|
|
|
|
|
61
|
50
|
|
|
50
|
1
|
163
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
50
|
|
|
|
|
2587
|
my $params_ref = $self->get_params(); |
64
|
|
|
|
|
|
|
|
65
|
50
|
50
|
33
|
|
|
279
|
unless ( ( defined($params_ref) ) and ( scalar( @{$params_ref} ) >= 1 ) ) { |
|
50
|
|
|
|
|
258
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
die |
68
|
|
|
|
|
|
|
'Must have at least one value in the params attribute array reference' |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
50
|
|
|
|
|
193
|
my $file = $params_ref->[0]; |
73
|
|
|
|
|
|
|
|
74
|
50
|
50
|
33
|
|
|
386
|
if ( ( defined($file) ) and ( $file ne '' ) ) { |
75
|
|
|
|
|
|
|
|
76
|
50
|
50
|
|
|
|
2727
|
$self->set_dump_file($file) if ( defined($file) ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
die 'dump_file attribute must be defined'; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 store |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Serializes a arbitrary data reference to the file as returned by C<get_dump_file> method. That serialization is done with L<Storable> module C<nstore> function. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Expects as parameters a data reference. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns any value returned by the C<nstore> function. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub store { |
98
|
|
|
|
|
|
|
|
99
|
21
|
|
|
21
|
1
|
81
|
my ($self, $data_ref) = @_; |
100
|
|
|
|
|
|
|
|
101
|
21
|
50
|
|
|
|
109
|
confess "the received parameter is not a reference" |
102
|
|
|
|
|
|
|
if ( ref($data_ref) eq '' ); |
103
|
|
|
|
|
|
|
|
104
|
21
|
|
|
|
|
1012
|
nstore $data_ref, $self->get_dump_file(); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::Daemon::Action> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<Storable> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
133
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
134
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
135
|
|
|
|
|
|
|
(at your option) any later version. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
138
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
139
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
140
|
|
|
|
|
|
|
GNU General Public License for more details. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
143
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |