Added missing file
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Engine.pm
1 package DBM::Deep::Engine;
2
3 use 5.006_000;
4
5 use strict;
6 use warnings FATAL => 'all';
7
8 use DBM::Deep::Iterator ();
9
10 # File-wide notes:
11 # * Every method in here assumes that the storage has been appropriately
12 #   safeguarded. This can be anything from flock() to some sort of manual
13 #   mutex. But, it's the caller's responsability to make sure that this has
14 #   been done.
15
16 # Setup file and tag signatures.  These should never change.
17 sub SIG_FILE     () { 'DPDB' }
18 sub SIG_HEADER   () { 'h'    }
19 sub SIG_HASH     () { 'H'    }
20 sub SIG_ARRAY    () { 'A'    }
21 sub SIG_NULL     () { 'N'    }
22 sub SIG_DATA     () { 'D'    }
23 sub SIG_INDEX    () { 'I'    }
24 sub SIG_BLIST    () { 'B'    }
25 sub SIG_FREE     () { 'F'    }
26 sub SIG_SIZE     () {  1     }
27
28 =head2 get_next_key( $obj, $prev_key )
29
30 This takes an object that provides _base_offset() and an optional string
31 representing the prior key returned via a prior invocation of this method.
32
33 This method delegates to C<< DBM::Deep::Iterator->get_next_key() >>.
34
35 =cut
36
37 # XXX Add staleness here
38 sub get_next_key {
39     my $self = shift;
40     my ($obj, $prev_key) = @_;
41
42     # XXX Need to add logic about resetting the iterator if any key in the reference has changed
43     unless ( $prev_key ) {
44         $obj->{iterator} = DBM::Deep::Iterator->new({
45             base_offset => $obj->_base_offset,
46             engine      => $self,
47         });
48     }
49
50     return $obj->{iterator}->get_next_key( $obj );
51 }
52
53 1;
54 __END__