e39e18400188c85e738d28f4cd2ad67782a27497
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Task.pm
1 # $Id: Task.pm,v 1.2 2006-10-12 14:36:34 mike Exp $
2
3 package ZOOM::IRSpy::Task;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 =head1 NAME
10
11 ZOOM::IRSpy::Task - base class for tasks in IRSpy
12
13 =head1 SYNOPSIS
14
15  use ZOOM::IRSpy::Task;
16  package ZOOM::IRSpy::Task::SomeTask;
17  our @ISA = qw(ZOOM::IRSpy::Task);
18  # ... override methods
19
20 =head1 DESCRIPTION
21
22 This class provides a base-class from which individual IRSpy task
23 classes can be derived.  For example, C<ZOOM::IRSpy::Task::Search>
24 will represent a searching task, carrying with it a query, a pointer
25 to a result-set, etc.
26
27 The base class provides nothing more exciting than a link to a
28 callback function to be called when the task is complete, and a
29 pointer to the next task to be performed after this.
30
31 =cut
32
33 sub new {
34     my $class = shift();
35     my($conn, $udata, %cb) = @_;
36
37     return bless {
38         irspy => $conn->{irspy},
39         conn => $conn,
40         cb => \%cb,
41         udata => $udata,
42         timeRegistered => time(),
43     }, $class;
44 }
45
46
47 sub irspy {
48     my $this = shift();
49     return $this->{irspy};
50 }
51
52 sub conn {
53     my $this = shift();
54     return $this->{conn};
55 }
56
57 sub udata {
58     my $this = shift();
59     return $this->{udata};
60 }
61
62 sub run {
63     my $this = shift();
64     die "can't run base-class task $this";
65 }
66
67 sub render {
68     my $this = shift();
69     return "[base-class] " . ref($this);
70 }
71
72 use overload '""' => \&render;
73
74
75 =head1 SEE ALSO
76
77 ZOOM::IRSpy
78
79 =head1 AUTHOR
80
81 Mike Taylor, E<lt>mike@indexdata.comE<gt>
82
83 =head1 COPYRIGHT AND LICENSE
84
85 Copyright (C) 2006 by Index Data ApS.
86
87 This library is free software; you can redistribute it and/or modify
88 it under the same terms as Perl itself, either Perl version 5.8.7 or,
89 at your option, any later version of Perl 5 you may have available.
90
91 =cut
92
93 1;