Started refactoring of Iterator hierarchy
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Iterator.pm
CommitLineData
f0276afb 1package DBM::Deep::Iterator;
2
3use 5.006_000;
4
5use strict;
6use warnings FATAL => 'all';
7
19b913ce 8use DBM::Deep::Iterator::DBI ();
9use DBM::Deep::Iterator::File ();
5ae752e2 10
f0276afb 11=head1 NAME
12
13DBM::Deep::Iterator
14
15=head1 PURPOSE
16
17This is an internal-use-only object for L<DBM::Deep/>. It is the iterator
18for FIRSTKEY() and NEXTKEY().
19
20=head1 OVERVIEW
21
22This object
23
24=head1 METHODS
25
26=head2 new(\%params)
27
28The constructor takes a hashref of params. The hashref is assumed to have the
29following elements:
30
31=over 4
32
33=item * engine (of type L<DBM::Deep::Engine/>
34
35=item * base_offset (the base_offset of the invoking DBM::Deep object)
36
37=back
38
39=cut
40
41sub new {
42 my $class = shift;
43 my ($args) = @_;
44
45 my $self = bless {
46 breadcrumbs => [],
47 engine => $args->{engine},
48 base_offset => $args->{base_offset},
49 }, $class;
50
51 Scalar::Util::weaken( $self->{engine} );
52
53 return $self;
54}
55
56=head2 reset()
57
58This method takes no arguments.
59
60It will reset the iterator so that it will start from the beginning again.
61
62This method returns nothing.
63
64=cut
65
19b913ce 66sub reset { $_[0]{breadcrumbs} = []; return }
f0276afb 67
68=head2 get_sector_iterator( $loc )
69
19b913ce 70This takes a location. It will load the sector for $loc, then instantiate the
71right iteartor type for it.
f0276afb 72
73This returns the sector iterator.
74
75=cut
76
19b913ce 77sub get_sector_iterator { die "get_sector_iterator must be implemented in a child class" }
f0276afb 78
79=head2 get_next_key( $obj )
80
81=cut
82
19b913ce 83sub get_next_key { die "get_next_key must be implemented in a child class" }
f0276afb 84
851;
86__END__