X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute%2FNode.pm;h=bde0a74476ac51819a4a27817d43db39ab41a852;hb=ad7e69f78ee4c0593e1d7576a7c1fd3b13931f84;hp=ff3351b3d6aaac0ea698b3e3ca3f12ec0dac7e65;hpb=148f4d43135748ba5aff985c50720b370ca1e336;p=spider.git diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index ff3351b3..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,8 +27,10 @@ use vars qw(%list %valid @ISA $max $filterdef); users => '0,Users,parray', usercount => '0,User Count', version => '0,Version', - np => '0,Using New Prot,yesno', - lid => '0,Last Msgid', + 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; @@ -210,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 { @@ -220,11 +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->{lid} = 0; + $self->{lastid} = {}; $list{$call} = $self; @@ -245,22 +263,6 @@ sub get_all return values %list; } -sub newid -{ - my $self = shift; - my $id = shift; - - return 0 if $id == $self->{lid}; - if ($id > $self->{lid}) { - $self->{lid} = $id; - return 1; - } elsif ($self->{lid} - $id > 60000) { - $self->{id} = $id; - return 1; - } - return 0; -} - sub _addparent { my $self = shift; @@ -315,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;