X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FThingy.pm;fp=perl%2FThingy.pm;h=87ee391adece15a8da1ac799ee2e0ca0be1867c1;hb=048adf1eb39f866e0968e1443fb7307ec5fdc4a6;hp=885e7f0f5f4c0dc1a210a449390b5025978d7c87;hpb=8b3403b35f575d43a6c8b316ad4b5c6dd5289752;p=spider.git diff --git a/perl/Thingy.pm b/perl/Thingy.pm index 885e7f0f..87ee391a 100644 --- a/perl/Thingy.pm +++ b/perl/Thingy.pm @@ -10,6 +10,8 @@ package Thingy; +use strict; + 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)); @@ -20,6 +22,8 @@ $main::branch += $BRANCH; use DXChannel; use DXDebug; +use Thingy::Route; + use vars qw(@queue); @queue = (); # the thingy queue @@ -29,7 +33,15 @@ sub new my $class = shift; my $self = {@_}; + my ($type) = $class =~ /::(\w+)$/; + bless $self, $class; + $self->{_tonode} ||= '*'; + $self->{_fromnode} ||= $main::mycall; + $self->{_hoptime} ||= 0; + while (my ($k,$v) = each %$self) { + delete $self->{$k} unless defined $v; + } return $self; } @@ -44,7 +56,22 @@ sub process { 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 = $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;