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