/[wait]/cvs-head/lib/WAIT/Document/Multi.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /cvs-head/lib/WAIT/Document/Multi.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (show annotations)
Fri Dec 29 14:20:03 2000 UTC (23 years, 4 months ago) by ulpfr
File size: 1893 byte(s)
Typo in manual

1 # -*- Mode: Perl -*-
2 # $Basename$
3 # $Revision: 1.2 $
4 # Author : Marc Lehmann
5 # Created On : June 2000
6 # Last Modified By: Ulrich Pfeifer
7 # Last Modified On: Fri Dec 29 12:56:35 2000
8 # Language : CPerl
9
10 package WAIT::Document::Multi;
11
12 use WAIT::Document::Base;
13 use base 'WAIT::Document::Base';
14
15 =head1 NAME
16
17 WAIT::Document::Multi - access class that joins multiple access objects into a single one
18
19 =head1 SYNOPSIS
20
21 use WAIT::Document::Multi;
22
23 tie %acc, WAIT::Document::Multi::,
24 access1 => <first access object>,
25 access2 => <second acces sobject>;
26
27 =head1 DESCRIPTION
28
29 This WAIT access class accepts any number of "domain name" => "access
30 object" pairs and creates a unified view over all of these access objects.
31
32 The access objects must be actual objects, not tied hash references.
33
34 The document id's are generated by appending the domain name, a binary
35 zero and the document id of the underlying access object.
36
37 =cut
38
39 sub new {
40 my $class = shift,
41 my %unused;
42 tie %unused, $class, @_;
43 }
44
45 sub TIEHASH {
46 my $type = shift;
47 my %acc = @_;
48 my ($fst, %nxt);
49 for (keys %acc) {
50 $nxt{$_} = $fst; $fst = $_;
51 }
52 bless {
53 acc => \%acc,
54 fst => $fst,
55 nxt => \%nxt,
56 }, ref $type || $type;
57 }
58
59 sub FETCH {
60 my $self = shift;
61 my ($dom, $key) = split /\x00/, shift, 2;
62 $self->{acc}{$dom}->FETCH($key);
63 }
64
65 sub FIRSTKEY {
66 my $self = shift;
67 my $dom = $self->{fst};
68 "$dom\x00".$self->{acc}{$dom}->FIRSTKEY;
69 }
70
71 sub NEXTKEY {
72 my $self = shift;
73 my ($dom, $key) = split /\x00/, shift, 2;
74 my $nxt = $self->{acc}{$dom}->NEXTKEY($key);
75 unless ($nxt) {
76 $dom = $self->{nxt}{$dom};
77 return unless $dom;
78 $nxt = $self->{acc}{$dom}->FIRSTKEY;
79 }
80 "$dom\x00$nxt";
81 }
82
83 =head1 AUTHOR
84
85 Marc Lehmann <pcg@goof.com>
86 http://www.goof.com/pcg/marc/
87
88 =cut
89
90 1;
91

Properties

Name Value
cvs2svn:cvs-rev 1.2

  ViewVC Help
Powered by ViewVC 1.1.26