ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ObjectUtilities/test/testObject.pm
Revision: 1.2
Committed: Fri Dec 17 10:55:21 1999 UTC (25 years, 5 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +9 -3 lines
Log Message:
working

File Contents

# User Rev Content
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 williamc 1.2 use ObjectUtilities::ObjectBase;
19 williamc 1.1 require 5.004;
20 williamc 1.2 @ISA=qw(ObjectUtilities::ObjectBase);
21 williamc 1.1
22     sub new {
23     my $class=shift;
24     my $name=shift;
25     $self={};
26     $self->{name}=$name;
27     bless $self, $class;
28     return $self;
29     }
30    
31     sub name {
32     my $self=shift;
33     return $self->{name};
34     }
35    
36     sub store {
37     my $self=shift;
38 williamc 1.2 my $location=shift;
39     my $fh=$self->openfile(">".$location);
40 williamc 1.1
41     print $fh $self->{name};
42 williamc 1.2 $fh->close();
43 williamc 1.1 }
44    
45     sub restore {
46     my $self=shift;
47 williamc 1.2 my $location=shift;
48     my $fh=$self->openfile("<".$location);
49 williamc 1.1
50 williamc 1.2 $self->{name}=<$fh>;
51     close $fh;
52 williamc 1.1 }