Many radical changes to the IRSpy engine, enabling a far more asynchronous approach...
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Task.pm
1 # $Id: Task.pm,v 1.1 2006-10-06 11:33:07 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, %cb) = @_;
36
37     return bless {
38         irspy => $conn->{irspy},
39         conn => $conn,
40         cb => \%cb,
41         timeRegistered => time(),
42     }, $class;
43 }
44
45
46 sub irspy {
47     my $this = shift();
48     return $this->{irspy};
49 }
50
51 sub conn {
52     my $this = shift();
53     return $this->{conn};
54 }
55
56 sub run {
57     my $this = shift();
58     die "can't run base-class task $this";
59 }
60
61 sub render {
62     my $this = shift();
63     return "[base-class] " . ref($this);
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;