3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.15 2002/12/05 13:55:21 joko |
7 |
|
# + now utilizing 'object2hash' instead of 'var_deref' |
8 |
|
# + played around with having fresh-objects - no progress.... |
9 |
|
# |
10 |
|
# Revision 1.14 2002/12/05 09:40:30 jonen |
11 |
|
# + added option->{destroy} at getObject for unloading all instance |
12 |
|
# |
13 |
# Revision 1.13 2002/12/05 07:59:04 joko |
# Revision 1.13 2002/12/05 07:59:04 joko |
14 |
# + now using Tie::SecureHash as a base for the COREHANDLE |
# + now using Tie::SecureHash as a base for the COREHANDLE |
15 |
# + former public COREHANDLE becomes private _COREHANDLE now |
# + former public COREHANDLE becomes private _COREHANDLE now |
82 |
use libp qw( getNewPerlObjectByPkgName ); |
use libp qw( getNewPerlObjectByPkgName ); |
83 |
use Data::Storage::Result::Tangram; |
use Data::Storage::Result::Tangram; |
84 |
use Data::Compare::Struct qw( isEmpty ); |
use Data::Compare::Struct qw( isEmpty ); |
85 |
use Data::Transform::Deep qw( var_deref ); |
use Data::Transform::Deep qw( object2hash ); |
86 |
use Data::Transform::Encode qw( var2utf8 ); |
use Data::Transform::Encode qw( var2utf8 ); |
87 |
|
|
88 |
|
|
496 |
sub getObject { |
sub getObject { |
497 |
my $self = shift; |
my $self = shift; |
498 |
my $oid = shift; |
my $oid = shift; |
499 |
|
my $options = shift; |
500 |
|
# TODO: create a deep_unload method |
501 |
|
# unload($oid) will only unload object, not deep object hashes |
502 |
|
$self->{_COREHANDLE}->unload() if($options->{destroy}); |
503 |
# TODO: review this |
# TODO: review this |
504 |
#if (!$self->{COREHANDLE}) { return; } |
#if (!$self->{COREHANDLE}) { return; } |
505 |
return $self->{_COREHANDLE}->load($oid); |
return $self->{_COREHANDLE}->load($oid); |
509 |
my $self = shift; |
my $self = shift; |
510 |
my $oid = shift; |
my $oid = shift; |
511 |
my $options = shift; |
my $options = shift; |
512 |
my $obj = $self->getObject($oid); |
my $obj = $self->getObject($oid, $options); |
513 |
my $deref = var_deref($obj); |
|
514 |
var2utf8($deref) if ($options->{utf8}); |
# build options (a callback to unload autovivified objects) for 'expand' |
515 |
undef($obj) if($options->{destroy}); |
# TODO: use $logger to write to debug here! |
516 |
return $deref; |
my $cb; # = sub {}; |
517 |
|
=pod |
518 |
|
if ($options->{destroy}) { |
519 |
|
$options->{cb}->{destroy} = sub { |
520 |
|
print "================ DESTROY", "\n"; |
521 |
|
my $object = shift; |
522 |
|
#print Dumper($object); |
523 |
|
$self->{_COREHANDLE}->unload($object); |
524 |
|
#undef($object); |
525 |
|
}; |
526 |
|
} |
527 |
|
=cut |
528 |
|
|
529 |
|
my $hash = object2hash($obj, $options); |
530 |
|
#$options->{cb}->{destroy}->($obj); |
531 |
|
#$self->{_COREHANDLE}->unload($obj); |
532 |
|
|
533 |
|
# convert values in hash to utf8 to be ready for (e.g.) encapsulation in XML |
534 |
|
# now done in object2hash |
535 |
|
#var2utf8($hash) if ($options->{utf8}); |
536 |
|
|
537 |
|
# old (wrong) attempts to get rid of used instances, if requested |
538 |
|
#$obj->clear_refs; |
539 |
|
#$self->{COREHANDLE}->unload($obj) if($options->{destroy}); |
540 |
|
#$obj->DESTROY; |
541 |
|
#undef($obj) if($options->{destroy}); |
542 |
|
|
543 |
|
return $hash; |
544 |
} |
} |
545 |
|
|
546 |
sub getSchema { |
sub getSchema { |