1 |
williamc |
1.1 |
#
|
2 |
|
|
# testObject.pm
|
3 |
|
|
#
|
4 |
|
|
# Originally Written by Christopher Williams
|
5 |
|
|
#
|
6 |
|
|
# Description
|
7 |
|
|
# -----------
|
8 |
|
|
# Persistent testObject used in the ObjectStore unit test
|
9 |
|
|
#
|
10 |
|
|
# Interface
|
11 |
|
|
# ---------
|
12 |
|
|
# new(name) : A new testObject object
|
13 |
|
|
# store(filhandle) : store to filehandle
|
14 |
|
|
# restore(filehandle) : restore from filehandle
|
15 |
|
|
# name() : return the name it was initialised with
|
16 |
|
|
|
17 |
|
|
package ObjectUtilities::test::testObject;
|
18 |
|
|
require 5.004;
|
19 |
|
|
|
20 |
|
|
sub new {
|
21 |
|
|
my $class=shift;
|
22 |
|
|
my $name=shift;
|
23 |
|
|
$self={};
|
24 |
|
|
$self->{name}=$name;
|
25 |
|
|
bless $self, $class;
|
26 |
|
|
return $self;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
sub name {
|
30 |
|
|
my $self=shift;
|
31 |
|
|
return $self->{name};
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
sub store {
|
35 |
|
|
my $self=shift;
|
36 |
|
|
my $fh=shift;
|
37 |
|
|
|
38 |
|
|
print $fh $self->{name};
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
sub restore {
|
42 |
|
|
my $self=shift;
|
43 |
|
|
my $fh=shift;
|
44 |
|
|
|
45 |
|
|
$self->{name}=<$fh>;
|
46 |
|
|
}
|