X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute%2FNode.pm;h=d1b0b1647fd304ff048ab4b7e150d64fa48e6e2d;hb=db0959118b4c5045e842cf07c399e2924bd6ca10;hp=1fbd8f71a291a1cddab0b6c71430bea16c1610cb;hpb=dbf7523a9b228dbdf1d03109afde351b8b194fab;p=spider.git diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 1fbd8f71..d1b0b164 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -29,8 +29,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 +212,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 +240,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 +265,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 +319,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;