--- nfo/perl/libs/Data/Storage/Result/Tangram.pm 2002/12/05 08:01:26 1.2 +++ nfo/perl/libs/Data/Storage/Result/Tangram.pm 2003/06/25 22:59:59 1.7 @@ -1,8 +1,23 @@ ############################################ # -# $Id: Tangram.pm,v 1.2 2002/12/05 08:01:26 joko Exp $ +# $Id: Tangram.pm,v 1.7 2003/06/25 22:59:59 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.7 2003/06/25 22:59:59 joko +# tweaked behaviour: only "->close" result if it is of type "Tangram::Cursor" +# +# Revision 1.6 2003/04/09 07:11:01 joko +# minor fix +# +# Revision 1.5 2003/04/09 02:09:47 joko +# bugfix: check for existance of '->close'-method before calling it on the 'RESULTHANDLE'-instance +# +# Revision 1.4 2003/03/27 15:31:15 joko +# fixes to modules regarding new namespace(s) below Data::Mungle::* +# +# Revision 1.3 2003/01/31 06:34:49 joko +# + fixes to 'getNextEntry' and 'getStatus' +# # Revision 1.2 2002/12/05 08:01:26 joko # + sub getStatus utilizing isEmpty to determine if result is set/unset and/or filled/unfilled # @@ -20,12 +35,26 @@ use base ("Data::Storage::Result::Abstract"); use Data::Dumper; -use Data::Compare::Struct qw( isEmpty ); +use Data::Mungle::Compare::Struct qw( isEmpty ); sub DESTROY { my $self = shift; + + my $is_object = 0; + #$logger->debug( __PACKAGE__ . "->" . "DESTROY" ); - $self->{RESULTHANDLE} && $self->{RESULTHANDLE}->close(); + #eval { + #print "ref: ", ref($self->{RESULTHANDLE}), "\n"; + + # object handle destructor + if ($self->{resulthandle_type} eq 'Tangram::Cursor') { + #$self->{RESULTHANDLE} && ref($self->{RESULTHANDLE}) && + #ref($self->{RESULTHANDLE}) && $self->{RESULTHANDLE}->can('close') && $self->{RESULTHANDLE}->close(); + $self->{RESULTHANDLE}->close(); + } + + # delete ref? + delete $self->{RESULTHANDLE}; } sub getNextEntry { @@ -37,6 +66,10 @@ # is result already opened? if ($self->{open}) { $self->{entry_count}++; + + # NEW as of 2003-06-24: RESULTHANDLE == ARRAY + return $self->{RESULTHANDLE}->[$self->{entry_count}] if (ref($self->{RESULTHANDLE}) eq 'ARRAY'); + return $self->{RESULTHANDLE}->next() if $self->{resulthandle_type} eq 'Tangram::Cursor'; return $self->{members}->[$self->{entry_count}] @@ -45,6 +78,11 @@ # open result! } else { $self->{entry_count} = 0; + $self->{open} = 1; + + # NEW as of 2003-06-24: RESULTHANDLE == ARRAY + return $self->{RESULTHANDLE}->[$self->{entry_count}] if (ref($self->{RESULTHANDLE}) eq 'ARRAY'); + return $self->{RESULTHANDLE}->execute() if $self->{resulthandle_type} eq 'Tangram::Cursor'; #print Dumper($self->{RESULTHANDLE}->members()); exit; @@ -53,19 +91,24 @@ $self->{members} = \@members; return $self->{members}->[$self->{entry_count}]; } - $self->{open} = 1; } } sub getStatus { my $self = shift; my $status; + + $self->{resulthandle_type} ||= ''; + if ($self->{resulthandle_type} eq 'Tangram::Cursor') { +=pod + print Dumper($self->{RESULTHANDLE}); $status = { err => $self->{RESULTHANDLE}->err, errstr => $self->{RESULTHANDLE}->errstr, state => $self->{RESULTHANDLE}->state, }; +=cut } if ($self->{resulthandle_type} eq 'Set::Object') { #print Dumper($self->{RESULTHANDLE}->members());