Got some basic functionality working. Still isn't fully functional (only the specifie...
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Sector / DBI.pm
1 package DBM::Deep::Sector::DBI;
2
3 use 5.006_000;
4
5 use strict;
6 use warnings FATAL => 'all';
7
8 use base qw( DBM::Deep::Sector );
9
10 use DBM::Deep::Sector::DBI::Reference ();
11 use DBM::Deep::Sector::DBI::Scalar ();
12
13 sub _init {
14 }
15
16 sub free {
17     my $self = shift;
18
19     $self->engine->storage->delete_from(
20         $self->table, $self->offset,
21     );
22 }
23
24 sub reload {
25     my $self = shift;
26     $self->_init;
27 }
28
29 sub load {
30     my $self = shift;
31     my ($engine, $offset, $type) = @_;
32
33     if ( $type eq 'refs' ) {
34         return DBM::Deep::Sector::DBI::Reference->new({
35             engine => $engine,
36             offset => $offset,
37         });
38     }
39     elsif ( $type eq 'datas' ) {
40         return DBM::Deep::Sector::DBI::Scalar->new({
41             engine => $engine,
42             offset => $offset,
43         });
44     }
45
46     DBM::Deep->_throw_error( "'$offset': Don't know what to do with type '$type'" );
47 }
48
49 1;
50 __END__