| 1 |
joko |
1.1 |
# (c) Sound Object Logic 2000-2001 |
| 2 |
|
|
|
| 3 |
|
|
use strict; |
| 4 |
|
|
|
| 5 |
|
|
package Tangram::AbstractHash; |
| 6 |
|
|
|
| 7 |
|
|
use Tangram::Coll; |
| 8 |
|
|
use base qw( Tangram::Coll ); |
| 9 |
|
|
|
| 10 |
|
|
use Carp; |
| 11 |
|
|
|
| 12 |
|
|
sub content |
| 13 |
|
|
{ |
| 14 |
|
|
shift; |
| 15 |
|
|
@{shift()}; |
| 16 |
|
|
} |
| 17 |
|
|
|
| 18 |
|
|
sub demand |
| 19 |
|
|
{ |
| 20 |
|
|
my ($self, $def, $storage, $obj, $member, $class) = @_; |
| 21 |
|
|
|
| 22 |
|
|
print $Tangram::TRACE "loading $member\n" if $Tangram::TRACE; |
| 23 |
|
|
|
| 24 |
|
|
my %coll; |
| 25 |
|
|
|
| 26 |
|
|
if (my $prefetch = $storage->{PREFETCH}{$class}{$member}{$storage->id($obj)}) |
| 27 |
|
|
{ |
| 28 |
|
|
%coll = %$prefetch; |
| 29 |
|
|
} |
| 30 |
|
|
else |
| 31 |
|
|
{ |
| 32 |
|
|
my $cursor = $self->cursor($def, $storage, $obj, $member); |
| 33 |
|
|
|
| 34 |
|
|
for (my $item = $cursor->select; $item; $item = $cursor->next) |
| 35 |
|
|
{ |
| 36 |
|
|
my $slot = shift @{ $cursor->{-residue} }; |
| 37 |
|
|
$coll{$slot} = $item; |
| 38 |
|
|
} |
| 39 |
|
|
} |
| 40 |
|
|
|
| 41 |
|
|
$storage->{scratch}{ref($self)}{$storage->id($obj)}{$member} = { |
| 42 |
|
|
map { $_ => ($coll{$_} && $storage->id( $coll{$_} ) ) } keys %coll }; |
| 43 |
|
|
|
| 44 |
|
|
return \%coll; |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
1; |