projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add more code gradually
[spider.git]
/
perl
/
Thingy.pm
diff --git
a/perl/Thingy.pm
b/perl/Thingy.pm
index cf057957c8e7e415149b3d1aaef036f672b796a4..785428cf42c6d7365a9d125405716c7de8e85ba9 100644
(file)
--- a/
perl/Thingy.pm
+++ b/
perl/Thingy.pm
@@
-10,9
+10,11
@@
package Thingy;
package Thingy;
+use strict;
+
use vars qw($VERSION $BRANCH);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
use vars qw($VERSION $BRANCH);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/
||
(0,0));
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/
,
(0,0));
$main::build += $VERSION;
$main::branch += $BRANCH;
$main::build += $VERSION;
$main::branch += $BRANCH;
@@
-20,7
+22,11
@@
$main::branch += $BRANCH;
use DXChannel;
use DXDebug;
use DXChannel;
use DXDebug;
-our @queue;
+use Thingy::Hi;
+use Thingy::Route;
+
+use vars qw(@queue);
+@queue = (); # the thingy queue
# we expect all thingies to be subclassed
sub new
# we expect all thingies to be subclassed
sub new
@@
-28,12
+34,19
@@
sub new
my $class = shift;
my $self = {@_};
my $class = shift;
my $self = {@_};
+ my ($type) = $class =~ /::(\w+)$/;
+
bless $self, $class;
bless $self, $class;
+ $self->{_tonode} ||= '*';
+ $self->{_fromnode} ||= $main::mycall;
+ while (my ($k,$v) = each %$self) {
+ delete $self->{$k} unless defined $v;
+ }
return $self;
}
# add the Thingy to the queue
return $self;
}
# add the Thingy to the queue
-sub
add
+sub
queue
{
push @queue, shift;
}
{
push @queue, shift;
}
@@
-43,7
+56,22
@@
sub process
{
my $t = pop @queue if @queue;
{
my $t = pop @queue if @queue;
- $t->process if $t;
+ if ($t) {
+
+ # go directly to this class's t= handler if there is one
+ my $type = lc $t->{t};
+ if ($type) {
+ # remove extraneous characters put there by the ungodly
+ $type =~ s/[^\w]//g;
+ $type = 'handle_' . $type;
+ if ($t->can($type)) {
+ no strict 'refs';
+ $t->$type;
+ return;
+ }
+ }
+ $t->normal;
+ }
}
1;
}
1;