X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute%2FNode.pm;h=bde0a74476ac51819a4a27817d43db39ab41a852;hb=ad7e69f78ee4c0593e1d7576a7c1fd3b13931f84;hp=49e241dddf5b6b7ef265861a5d2498da1c0af903;hpb=412fb1b9e4070d7791f4e986b55bbc0c06f612ea;p=spider.git diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 49e241dd..bde0a744 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -11,14 +11,12 @@ package Route::Node; use DXDebug; use Route; use Route::User; +use DXUtil; 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; -$main::build += $VERSION; -$main::branch += $BRANCH; +($VERSION, $BRANCH) = dxver( q$Revision$); use vars qw(%list %valid @ISA $max $filterdef); @ISA = qw(Route); @@ -29,6 +27,10 @@ use vars qw(%list %valid @ISA $max $filterdef); users => '0,Users,parray', usercount => '0,User Count', version => '0,Version', + handle_xml => '0,Using XML,yesno', + lastmsg => '0,Last Route Msg,atime', + lastid => '0,Last Route MsgID', + do_pc92 => '0,Uses pc92,yesno', ); $filterdef = $Route::filterdef; @@ -189,6 +191,12 @@ sub nodes return @{$self->{nodes}}; } +sub parents +{ + my $self = shift; + return @{$self->{parent}}; +} + sub rnodes { my $self = shift; @@ -202,6 +210,24 @@ sub rnodes return @out; } +# this takes in a list of node and user calls (not references) from +# a config type update for a node and returns +# the differences as lists of things that have gone away +# and things that have been added. +sub calc_config_changes +{ + my $self = shift; + my %nodes = map {$_ => 1} @{$self->{nodes}}; + my %users = map {$_ => 1} @{$self->{users}}; + my $cnodes = shift; + my $cusers = shift; + my (@dnodes, @dusers, @nnodes, @nusers); + push @nnodes, map {my @r = $nodes{$_} ? () : $_; delete $nodes{$_}; @r} @$cnodes; + push @dnodes, keys %nodes; + push @nusers, map {my @r = $users{$_} ? () : $_; delete $users{$_}; @r} @$cusers; + push @dusers, keys %users; + return (\@dnodes, \@dusers, \@nnodes, \@nusers); +} sub new { @@ -212,10 +238,11 @@ sub new my $self = $pkg->SUPER::new($call); $self->{parent} = ref $pkg ? [ $pkg->{call} ] : [ ]; - $self->{version} = shift; - $self->{flags} = shift; + $self->{version} = shift || 5000; + $self->{flags} = shift || Route::here(1); $self->{users} = []; $self->{nodes} = []; + $self->{lastid} = {}; $list{$call} = $self; @@ -290,19 +317,16 @@ sub DESTROY sub AUTOLOAD { no strict; - - my $self = shift; - $name = $AUTOLOAD; + my $name = $AUTOLOAD; return if $name =~ /::DESTROY$/; - $name =~ s/.*:://o; + $name =~ s/^.*:://o; confess "Non-existant field '$AUTOLOAD'" unless $valid{$name} || $Route::valid{$name}; # this clever line of code creates a subroutine which takes over from autoload # from OO Perl - Conway -# print "AUTOLOAD: $AUTOLOAD\n"; -# *{$AUTOLOAD} = sub {my $self = shift; @_ ? $self->{$name} = shift : $self->{$name}} ; - @_ ? $self->{$name} = shift : $self->{$name} ; + *$AUTOLOAD = sub {$_[0]->{$name} = $_[1] if @_ > 1; return $_[0]->{$name}}; + goto &$AUTOLOAD; } 1;