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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Wed Jun 25 22:59:59 2003 UTC (21 years ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +26 -2 lines
tweaked behaviour: only "->close" result if it is of type "Tangram::Cursor"

1 joko 1.1 ############################################
2     #
3 joko 1.7 # $Id: Tangram.pm,v 1.6 2003/04/09 07:11:01 joko Exp $
4 joko 1.2 #
5     # $Log: Tangram.pm,v $
6 joko 1.7 # Revision 1.6 2003/04/09 07:11:01 joko
7     # minor fix
8     #
9 joko 1.6 # Revision 1.5 2003/04/09 02:09:47 joko
10     # bugfix: check for existance of '->close'-method before calling it on the 'RESULTHANDLE'-instance
11     #
12 joko 1.5 # Revision 1.4 2003/03/27 15:31:15 joko
13     # fixes to modules regarding new namespace(s) below Data::Mungle::*
14     #
15 joko 1.4 # Revision 1.3 2003/01/31 06:34:49 joko
16     # + fixes to 'getNextEntry' and 'getStatus'
17     #
18 joko 1.3 # Revision 1.2 2002/12/05 08:01:26 joko
19     # + sub getStatus utilizing isEmpty to determine if result is set/unset and/or filled/unfilled
20     #
21 joko 1.2 # Revision 1.1 2002/11/29 04:55:45 joko
22     # + initial check-in
23 joko 1.1 #
24     #
25     ############################################
26    
27    
28     package Data::Storage::Result::Tangram;
29    
30     use strict;
31     use warnings;
32    
33     use base ("Data::Storage::Result::Abstract");
34     use Data::Dumper;
35 joko 1.4 use Data::Mungle::Compare::Struct qw( isEmpty );
36 joko 1.1
37     sub DESTROY {
38     my $self = shift;
39 joko 1.7
40     my $is_object = 0;
41    
42 joko 1.1 #$logger->debug( __PACKAGE__ . "->" . "DESTROY" );
43 joko 1.7 #eval {
44     #print "ref: ", ref($self->{RESULTHANDLE}), "\n";
45    
46     # object handle destructor
47     if ($self->{resulthandle_type} eq 'Tangram::Cursor') {
48     #$self->{RESULTHANDLE} && ref($self->{RESULTHANDLE}) &&
49     #ref($self->{RESULTHANDLE}) && $self->{RESULTHANDLE}->can('close') && $self->{RESULTHANDLE}->close();
50     $self->{RESULTHANDLE}->close();
51     }
52    
53     # delete ref?
54     delete $self->{RESULTHANDLE};
55 joko 1.1 }
56    
57     sub getNextEntry {
58     my $self = shift;
59    
60     return if !$self->{RESULTHANDLE};
61     $self->{resulthandle_type} = ref($self->{RESULTHANDLE}) if !$self->{resulthandle_type};
62    
63     # is result already opened?
64     if ($self->{open}) {
65     $self->{entry_count}++;
66 joko 1.7
67     # NEW as of 2003-06-24: RESULTHANDLE == ARRAY
68     return $self->{RESULTHANDLE}->[$self->{entry_count}] if (ref($self->{RESULTHANDLE}) eq 'ARRAY');
69    
70 joko 1.1 return $self->{RESULTHANDLE}->next()
71     if $self->{resulthandle_type} eq 'Tangram::Cursor';
72     return $self->{members}->[$self->{entry_count}]
73     if $self->{resulthandle_type} eq 'Set::Object';
74    
75 joko 1.2 # open result!
76 joko 1.1 } else {
77     $self->{entry_count} = 0;
78 joko 1.3 $self->{open} = 1;
79 joko 1.7
80     # NEW as of 2003-06-24: RESULTHANDLE == ARRAY
81     return $self->{RESULTHANDLE}->[$self->{entry_count}] if (ref($self->{RESULTHANDLE}) eq 'ARRAY');
82 joko 1.3
83 joko 1.1 return $self->{RESULTHANDLE}->execute()
84     if $self->{resulthandle_type} eq 'Tangram::Cursor';
85     #print Dumper($self->{RESULTHANDLE}->members()); exit;
86     if ($self->{resulthandle_type} eq 'Set::Object') {
87     my @members = $self->{RESULTHANDLE}->members();
88     $self->{members} = \@members;
89     return $self->{members}->[$self->{entry_count}];
90     }
91 joko 1.2 }
92     }
93    
94     sub getStatus {
95     my $self = shift;
96     my $status;
97 joko 1.6
98     $self->{resulthandle_type} ||= '';
99    
100 joko 1.2 if ($self->{resulthandle_type} eq 'Tangram::Cursor') {
101 joko 1.3 =pod
102     print Dumper($self->{RESULTHANDLE});
103 joko 1.2 $status = {
104     err => $self->{RESULTHANDLE}->err,
105     errstr => $self->{RESULTHANDLE}->errstr,
106     state => $self->{RESULTHANDLE}->state,
107     };
108 joko 1.3 =cut
109 joko 1.2 }
110     if ($self->{resulthandle_type} eq 'Set::Object') {
111     #print Dumper($self->{RESULTHANDLE}->members());
112     $status = {
113     empty => isEmpty($self->{RESULTHANDLE}),
114     },
115 joko 1.1 }
116 joko 1.2 return $status;
117 joko 1.1 }
118    
119    
120     1;

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