2 package ZOOM::IRSpy::Task;
12 ZOOM::IRSpy::Task - base class for tasks in IRSpy
16 use ZOOM::IRSpy::Task;
17 package ZOOM::IRSpy::Task::SomeTask;
18 our @ISA = qw(ZOOM::IRSpy::Task);
19 # ... override methods
23 This class provides a base-class from which individual IRSpy task
24 classes can be derived. For example, C<ZOOM::IRSpy::Task::Search>
25 will represent a searching task, carrying with it a query, a pointer
28 The base class provides nothing more exciting than a link to a
29 callback function to be called when the task is complete, and a
30 pointer to the next task to be performed after this.
36 my($conn, $udata, $options, %cb) = @_;
39 irspy => $conn->{irspy},
44 timeRegistered => time(),
47 #Scalar::Util::weaken($this->{irspy});
48 #Scalar::Util::weaken($this->{udata});
56 return $this->{irspy};
66 return $this->{udata};
71 die "can't run base-class task $this";
74 # In general, this sets the Connection's options to what is in the
75 # task's option hash and sets the option-hash entry to the
76 # Connection's old value of the option: this means that calling this
77 # twice restores the state to how it was before. (That's not quite
78 # true as its impossible to unset an option that was previously set:
79 # such options are instead set to the empty string.)
81 # As a special case, options in the task's option-hash whose names
82 # begin with an asterisk are taken to be persistent: they are set into
83 # the Connection (with the leading asterisk removed) and deleted from
84 # the task's option-hash so that they will NOT be reset the next time
85 # this function is called.
90 foreach my $key (sort keys %{ $this->{options} }) {
91 my $value = $this->{options}->{$key};
92 my $persistent = ($key =~ s/^\*//);
93 $value = "" if !defined $value;
94 $this->conn()->log("irspy_debug", "$this setting option '$key' -> ",
95 defined $value ? "'$value'" : "undefined");
96 my $old = $this->conn()->option($key, $value);
98 delete $this->{options}->{"*$key"}
100 $this->{options}->{$key} = $old;
107 return "[base-class] " . ref($this);
110 use overload '""' => \&render;
119 Mike Taylor, E<lt>mike@indexdata.comE<gt>
121 =head1 COPYRIGHT AND LICENSE
123 Copyright (C) 2006 by Index Data ApS.
125 This library is free software; you can redistribute it and/or modify
126 it under the same terms as Perl itself, either Perl version 5.8.7 or,
127 at your option, any later version of Perl 5 you may have available.