Commit | Line | Data |
d6ecf579 |
1 | package DBM::Deep::Sector::DBI; |
2 | |
3 | use 5.006_000; |
4 | |
5 | use strict; |
6 | use warnings FATAL => 'all'; |
7 | |
a4d36ff6 |
8 | use base qw( DBM::Deep::Sector ); |
9 | |
10 | use DBM::Deep::Sector::DBI::Reference (); |
11 | use DBM::Deep::Sector::DBI::Scalar (); |
12 | |
a4d36ff6 |
13 | sub free { |
14 | my $self = shift; |
15 | |
16 | $self->engine->storage->delete_from( |
17 | $self->table, $self->offset, |
18 | ); |
19 | } |
20 | |
21 | sub reload { |
22 | my $self = shift; |
23 | $self->_init; |
24 | } |
25 | |
26 | sub load { |
27 | my $self = shift; |
28 | my ($engine, $offset, $type) = @_; |
29 | |
30 | if ( $type eq 'refs' ) { |
31 | return DBM::Deep::Sector::DBI::Reference->new({ |
32 | engine => $engine, |
33 | offset => $offset, |
34 | }); |
35 | } |
36 | elsif ( $type eq 'datas' ) { |
350896ee |
37 | my $sector = DBM::Deep::Sector::DBI::Scalar->new({ |
a4d36ff6 |
38 | engine => $engine, |
39 | offset => $offset, |
40 | }); |
350896ee |
41 | |
42 | if ( $sector->{data_type} eq 'R' ) { |
43 | return $self->load( |
cf4a1344 |
44 | $engine, $sector->{value}, 'refs', |
350896ee |
45 | ); |
46 | } |
47 | |
48 | return $sector; |
a4d36ff6 |
49 | } |
50 | |
51 | DBM::Deep->_throw_error( "'$offset': Don't know what to do with type '$type'" ); |
52 | } |
d6ecf579 |
53 | |
54 | 1; |
55 | __END__ |