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