1 |
joko |
1.1 |
############################################ |
2 |
|
|
# |
3 |
joko |
1.5 |
# $Id: Tangram.pm,v 1.4 2003/03/27 15:31:15 joko Exp $ |
4 |
joko |
1.2 |
# |
5 |
|
|
# $Log: Tangram.pm,v $ |
6 |
joko |
1.5 |
# Revision 1.4 2003/03/27 15:31:15 joko |
7 |
|
|
# fixes to modules regarding new namespace(s) below Data::Mungle::* |
8 |
|
|
# |
9 |
joko |
1.4 |
# Revision 1.3 2003/01/31 06:34:49 joko |
10 |
|
|
# + fixes to 'getNextEntry' and 'getStatus' |
11 |
|
|
# |
12 |
joko |
1.3 |
# 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 |
joko |
1.2 |
# Revision 1.1 2002/11/29 04:55:45 joko |
16 |
|
|
# + initial check-in |
17 |
joko |
1.1 |
# |
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 |
joko |
1.4 |
use Data::Mungle::Compare::Struct qw( isEmpty ); |
30 |
joko |
1.1 |
|
31 |
|
|
sub DESTROY { |
32 |
|
|
my $self = shift; |
33 |
|
|
#$logger->debug( __PACKAGE__ . "->" . "DESTROY" ); |
34 |
joko |
1.5 |
$self->{RESULTHANDLE} && $self->{RESULTHANDLE}->can('close') && $self->{RESULTHANDLE}->close(); |
35 |
joko |
1.1 |
} |
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 |
joko |
1.2 |
# open result! |
52 |
joko |
1.1 |
} else { |
53 |
|
|
$self->{entry_count} = 0; |
54 |
joko |
1.3 |
$self->{open} = 1; |
55 |
|
|
|
56 |
joko |
1.1 |
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 |
joko |
1.2 |
} |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
sub getStatus { |
68 |
|
|
my $self = shift; |
69 |
|
|
my $status; |
70 |
|
|
if ($self->{resulthandle_type} eq 'Tangram::Cursor') { |
71 |
joko |
1.3 |
=pod |
72 |
|
|
print Dumper($self->{RESULTHANDLE}); |
73 |
joko |
1.2 |
$status = { |
74 |
|
|
err => $self->{RESULTHANDLE}->err, |
75 |
|
|
errstr => $self->{RESULTHANDLE}->errstr, |
76 |
|
|
state => $self->{RESULTHANDLE}->state, |
77 |
|
|
}; |
78 |
joko |
1.3 |
=cut |
79 |
joko |
1.2 |
} |
80 |
|
|
if ($self->{resulthandle_type} eq 'Set::Object') { |
81 |
|
|
#print Dumper($self->{RESULTHANDLE}->members()); |
82 |
|
|
$status = { |
83 |
|
|
empty => isEmpty($self->{RESULTHANDLE}), |
84 |
|
|
}, |
85 |
joko |
1.1 |
} |
86 |
joko |
1.2 |
return $status; |
87 |
joko |
1.1 |
} |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
1; |