1 # $Id: Connection.pm,v 1.7 2006-11-16 17:18:43 mike Exp $
3 package ZOOM::IRSpy::Connection;
10 our @ISA = qw(ZOOM::Connection);
12 use ZOOM::IRSpy::Task::Connect;
13 use ZOOM::IRSpy::Task::Search;
14 use ZOOM::IRSpy::Task::Retrieve;
19 ZOOM::IRSpy::Connection - ZOOM::Connection subclass with IRSpy functionality
23 This class provides some additional private data and methods that are
24 used by IRSpy but which would be useless in any other application.
25 Keeping the private data in these objects removes the need for ugly
26 mappings in the IRSpy object itself; adding the methods makes the
27 application code cleaner.
29 The constructor takes an additional first argument, a reference to the
30 IRSpy object that it is associated with.
38 my $this = $class->SUPER::create(@_);
39 $this->{irspy} = $irspy;
40 $this->{record} = undef;
49 return $this->{irspy};
57 my $old = $this->{record};
58 $this->{record} = $new if defined $new;
66 return $this->{tasks};
74 my $old = $this->{current_task};
76 $this->{current_task} = $new;
77 $this->log("irspy_task", "set current task to $new");
88 my $old = $this->{next_task};
90 $this->{next_task} = $new;
91 $this->log("irspy_task", "set next task to $new");
100 my($level, @msg) = @_;
102 $this->irspy()->log($level, $this->option("host"), " ", @msg);
108 my($udata, $options, %cb) = @_;
110 my $task = new ZOOM::IRSpy::Task::Connect($this, $udata, $options, %cb);
111 $this->add_task($task);
115 sub irspy_search_pqf {
117 my($query, $udata, $options, %cb) = @_;
119 my $task = new ZOOM::IRSpy::Task::Search($query,
120 $this, $udata, $options, %cb);
121 $this->add_task($task);
125 sub irspy_rs_record {
127 my($rs, $index0, $udata, $options, %cb) = @_;
129 my $task = new ZOOM::IRSpy::Task::Retrieve($rs, $index0,
130 $this, $udata, $options, %cb);
131 $this->add_task($task);
139 my $tasks = $this->{tasks};
140 $tasks->[-1]->{next} = $task if @$tasks > 0;
142 $this->log("irspy_task", "added task $task");
148 return ref($this) . "(" . $this->option("host") . ")";
151 use overload '""' => \&render;
160 Mike Taylor, E<lt>mike@indexdata.comE<gt>
162 =head1 COPYRIGHT AND LICENSE
164 Copyright (C) 2006 by Index Data ApS.
166 This library is free software; you can redistribute it and/or modify
167 it under the same terms as Perl itself, either Perl version 5.8.7 or,
168 at your option, any later version of Perl 5 you may have available.