/[cvs]/nfo/perl/libs/Data/Storage/Result/Tangram.pm
ViewVC logotype

Contents of /nfo/perl/libs/Data/Storage/Result/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Wed Apr 9 02:09:47 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.4: +5 -2 lines
bugfix: check for existance of '->close'-method before calling it on the 'RESULTHANDLE'-instance

1 ############################################
2 #
3 # $Id: Tangram.pm,v 1.4 2003/03/27 15:31:15 joko Exp $
4 #
5 # $Log: Tangram.pm,v $
6 # Revision 1.4 2003/03/27 15:31:15 joko
7 # fixes to modules regarding new namespace(s) below Data::Mungle::*
8 #
9 # Revision 1.3 2003/01/31 06:34:49 joko
10 # + fixes to 'getNextEntry' and 'getStatus'
11 #
12 # Revision 1.2 2002/12/05 08:01:26 joko
13 # + sub getStatus utilizing isEmpty to determine if result is set/unset and/or filled/unfilled
14 #
15 # Revision 1.1 2002/11/29 04:55:45 joko
16 # + initial check-in
17 #
18 #
19 ############################################
20
21
22 package Data::Storage::Result::Tangram;
23
24 use strict;
25 use warnings;
26
27 use base ("Data::Storage::Result::Abstract");
28 use Data::Dumper;
29 use Data::Mungle::Compare::Struct qw( isEmpty );
30
31 sub DESTROY {
32 my $self = shift;
33 #$logger->debug( __PACKAGE__ . "->" . "DESTROY" );
34 $self->{RESULTHANDLE} && $self->{RESULTHANDLE}->can('close') && $self->{RESULTHANDLE}->close();
35 }
36
37 sub getNextEntry {
38 my $self = shift;
39
40 return if !$self->{RESULTHANDLE};
41 $self->{resulthandle_type} = ref($self->{RESULTHANDLE}) if !$self->{resulthandle_type};
42
43 # is result already opened?
44 if ($self->{open}) {
45 $self->{entry_count}++;
46 return $self->{RESULTHANDLE}->next()
47 if $self->{resulthandle_type} eq 'Tangram::Cursor';
48 return $self->{members}->[$self->{entry_count}]
49 if $self->{resulthandle_type} eq 'Set::Object';
50
51 # open result!
52 } else {
53 $self->{entry_count} = 0;
54 $self->{open} = 1;
55
56 return $self->{RESULTHANDLE}->execute()
57 if $self->{resulthandle_type} eq 'Tangram::Cursor';
58 #print Dumper($self->{RESULTHANDLE}->members()); exit;
59 if ($self->{resulthandle_type} eq 'Set::Object') {
60 my @members = $self->{RESULTHANDLE}->members();
61 $self->{members} = \@members;
62 return $self->{members}->[$self->{entry_count}];
63 }
64 }
65 }
66
67 sub getStatus {
68 my $self = shift;
69 my $status;
70 if ($self->{resulthandle_type} eq 'Tangram::Cursor') {
71 =pod
72 print Dumper($self->{RESULTHANDLE});
73 $status = {
74 err => $self->{RESULTHANDLE}->err,
75 errstr => $self->{RESULTHANDLE}->errstr,
76 state => $self->{RESULTHANDLE}->state,
77 };
78 =cut
79 }
80 if ($self->{resulthandle_type} eq 'Set::Object') {
81 #print Dumper($self->{RESULTHANDLE}->members());
82 $status = {
83 empty => isEmpty($self->{RESULTHANDLE}),
84 },
85 }
86 return $status;
87 }
88
89
90 1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed