1 package DBM::Deep::Engine::Sector;
6 use warnings FATAL => 'all';
11 my $self = bless $_[1], $_[0];
12 Scalar::Util::weaken( $self->{engine} );
20 #sub clone { DBM::Deep->_throw_error( "Must be implemented in the child class" ); }
22 sub engine { $_[0]{engine} }
23 sub offset { $_[0]{offset} }
24 sub type { $_[0]{type} }
29 return $self->engine->SIG_SIZE + $DBM::Deep::Engine::STALE_SIZE;
32 return $_[0]->SIG_SIZE + $DBM::Deep::Engine::STALE_SIZE;
39 my $e = $self->engine;
41 $self->write( 0, $e->SIG_FREE );
42 $self->write( $self->base_size, chr(0) x ($self->size - $self->base_size) );
44 my $free_meth = $self->free_meth;
45 $e->$free_meth( $self );
54 return substr( ${$self->engine->get_data( $self->offset, $self->size )}, $_[0] );
57 return substr( ${$self->engine->get_data( $self->offset, $self->size )}, $_[0], $_[1] );
60 die "read( start [, length ]): No parameters found.";
63 die "read( start [, length ]): Too many parameters found (@_).";
69 my ($start, $text) = @_;
71 substr( ${$self->engine->get_data( $self->offset, $self->size )}, $start, length($text) ) = $text;
78 $self->engine->add_dirty_sector( $self->offset );