tasks() simplified, now read-only.
Added next_task() get/set method, analogous to current_task()
Simplified add_task()
Removed start_task()
-# $Id: Connection.pm,v 1.1 2006-10-06 11:33:07 mike Exp $
+# $Id: Connection.pm,v 1.2 2006-10-11 16:46:01 mike Exp $
package ZOOM::IRSpy::Connection;
package ZOOM::IRSpy::Connection;
my $class = shift();
my $irspy = shift();
my $class = shift();
my $irspy = shift();
- my $this = $class->SUPER::new(@_);
+ my $this = $class->SUPER::create(@_);
$this->{irspy} = $irspy;
$this->{record} = undef;
$this->{irspy} = $irspy;
$this->{record} = undef;
- $this->{tasks} = undef;
sub tasks {
my $this = shift();
sub tasks {
my $this = shift();
- my $old = $this->{tasks};
- $this->{tasks} = $new if defined $new;
- return $old;
+sub next_task {
+ my $this = shift();
+ my($new) = @_;
+
+ my $old = $this->{next_task};
+ if (defined $new) {
+ $this->{next_task} = $new;
+ $this->log("irspy_debug", "set next task to $new");
+ }
+
+ return $old;
+}
+
+
sub log {
my $this = shift();
my($level, @msg) = @_;
sub log {
my $this = shift();
my($level, @msg) = @_;
my $this = shift();
my($task) = @_;
my $this = shift();
my($task) = @_;
- my $tasks = $this->tasks();
- if (!defined $tasks) {
- $this->tasks([ $task ]);
- } else {
- $tasks->[-1]->{next} = $task;
- push @$tasks, $task;
- }
-
+ my $tasks = $this->{tasks};
+ $tasks->[-1]->{next} = $task if @$tasks > 0;
+ push @$tasks, $task;
$this->log("irspy", "added task $task");
}
$this->log("irspy", "added task $task");
}
-sub start_task {
- my $this = shift();
- my($task) = @_;
- die "no task defined for " . $this->option("host")
- if !defined $task;
-
- $this->current_task($task);
- $task->run();
-}
-
-
=head1 SEE ALSO
ZOOM::IRSpy
=head1 SEE ALSO
ZOOM::IRSpy