X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCluster.pm;h=2160846547e9e542b5c80413c3bc8c1201e46ccf;hb=4e5b3de7a26563d94678fb790b8a1e2c4daaac8d;hp=c0ec375a88f56eabc3fe39e2fce91417564ae0af;hpb=3ba4a53a0fae7b6135ee9b8cd0ab4bbe352b4bdc;p=spider.git diff --git a/perl/DXCluster.pm b/perl/DXCluster.pm index c0ec375a..21608465 100644 --- a/perl/DXCluster.pm +++ b/perl/DXCluster.pm @@ -14,10 +14,8 @@ package DXCluster; -use Exporter; -@ISA = qw(Exporter); use DXDebug; -use Carp; +use DXUtil; use strict; use vars qw(%cluster %valid); @@ -25,13 +23,13 @@ use vars qw(%cluster %valid); %cluster = (); # this is where we store the dxcluster database %valid = ( - mynode => '0,Parent Node,showcall', + mynode => '0,Parent Node,DXCluster::showcall', call => '0,Callsign', confmode => '0,Conference Mode,yesno', here => '0,Here?,yesno', - dxchan => '5,Channel ref', + dxchan => '5,Channel ref,DXCluster::showcall', pcversion => '5,Node Version', - list => '5,User List,dolist', + list => '5,User List,DXCluster::dolist', users => '0,No of Users', ); @@ -102,6 +100,14 @@ sub field_prompt my ($self, $ele) = @_; return $valid{$ele}; } +# +# return a list of valid elements +# + +sub fields +{ + return keys(%valid); +} # this expects a reference to a list in a node NOT a ref to a node sub dolist @@ -110,7 +116,8 @@ sub dolist my $out; my $ref; - foreach $ref (@{$self}) { + foreach my $call (keys %{$self}) { + $ref = $$self{$call}; my $s = $ref->{call}; $s = "($s)" if !$ref->{here}; $out .= "$s "; @@ -136,12 +143,6 @@ sub cluster return " $DXNode::nodes nodes, $users local / $tot total users Max users $DXNode::maxusers Uptime $uptime"; } -#sub DESTROY -#{ -# my $self = shift; -# dbg('cluster', "destroying $self->{call}\n"); -#} - no strict; sub AUTOLOAD { @@ -152,6 +153,9 @@ sub AUTOLOAD $name =~ s/.*:://o; confess "Non-existant field '$AUTOLOAD'" if !$valid{$name}; + # this clever line of code creates a subroutine which takes over from autoload + # from OO Perl - Conway + *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ; @_ ? $self->{$name} = shift : $self->{$name} ; } @@ -303,5 +307,13 @@ sub dolist { } + +sub DESTROY +{ + my $self = shift; + undef $self->{list} if $self->{list}; +} + + 1; __END__