ce5f889c882af495243662fa1b23b7abe8c94c1f
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Task / Search.pm
1 # $Id: Search.pm,v 1.7 2006-11-16 14:58:55 mike Exp $
2
3 package ZOOM::IRSpy::Task::Search;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 use ZOOM::IRSpy::Task;
10 our @ISA = qw(ZOOM::IRSpy::Task);
11
12 =head1 NAME
13
14 ZOOM::IRSpy::Task::Search - a searching task for IRSpy
15
16 =head1 SYNOPSIS
17
18  ## to follow
19
20 =head1 DESCRIPTION
21
22  ## to follow
23
24 =cut
25
26 sub new {
27     my $class = shift();
28     my($query) = shift();
29
30     my $this = $class->SUPER::new(@_);
31     $this->{query} = $query;
32     $this->{rs} = undef;
33     return $this;
34 }
35
36 sub run {
37     my $this = shift();
38
39     $this->set_options();
40
41     my $conn = $this->conn();
42     my $query = $this->{query};
43     $this->irspy()->log("irspy_task", $conn->option("host"),
44                         " searching for '$query'");
45     $this->{rs} = $conn->search_pqf($query);
46     warn "no ZOOM-C level events queued by $this"
47         if $conn->is_idle();
48
49     $this->set_options();
50
51     # I want to catch the situation where a search is attempted on a
52     # not-yet opened connection (e.g. the Search::Title test is run
53     # before Ping) but since this situation doesn't involve the
54     # generation of a ZOOM event, the main loop won't see an error.
55     # So I check for it immediately:
56     $conn->_check();
57     # ### Unfortunately, this also fails to detect the condition I'm
58     # concerned with, so I think I am out of luck.
59 }
60
61 sub render {
62     my $this = shift();
63     return ref($this) . "(" . $this->{query} . ")";
64 }
65
66 use overload '""' => \&render;
67
68
69 =head1 SEE ALSO
70
71 ZOOM::IRSpy
72
73 =head1 AUTHOR
74
75 Mike Taylor, E<lt>mike@indexdata.comE<gt>
76
77 =head1 COPYRIGHT AND LICENSE
78
79 Copyright (C) 2006 by Index Data ApS.
80
81 This library is free software; you can redistribute it and/or modify
82 it under the same terms as Perl itself, either Perl version 5.8.7 or,
83 at your option, any later version of Perl 5 you may have available.
84
85 =cut
86
87 1;