2 # DX database control routines
4 # This manages the on-line cluster user 'database'
6 # This should all be pretty trees and things, but for now I
7 # just can't be bothered. If it becomes an issue I shall
10 # Copyright (c) 1998 - Dirk Koopman G1TLH
22 my %cluster = (); # this is where we store the dxcluster database
25 mynode => '0,Parent Node',
27 confmode => '0,Conference Mode,yesno',
28 here => '0,Here?,yesno',
29 dxchan => '5,Channel ref',
30 pcversion => '5,Node Version',
35 my ($pkg, $call, $confmode, $here, $dxchan) = @_;
36 die "$call is already alloced" if $cluster{$call};
38 $self->{call} = $call;
39 $self->{confmode} = $confmode;
40 $self->{here} = $here;
41 $self->{dxchan} = $dxchan;
43 $cluster{$call} = bless $self, $pkg;
47 # search for a call in the cluster
50 my ($pkg, $call) = @_;
51 return $cluster{$call};
57 return values(%cluster);
63 delete $cluster{$self->{call}};
67 # return a prompt for a field
70 my ($self, $ele) = @_;
80 return if $name =~ /::DESTROY$/;
83 die "Non-existant field '$AUTOLOAD'" if !$valid{$name};
84 @_ ? $self->{$name} = shift : $self->{$name} ;
88 # USER special routines
100 my ($pkg, $mynode, $call, $confmode, $here, $dxchan) = @_;
101 my $self = $pkg->alloc($call, $confmode, $here, $dxchan);
102 $self->{mynode} = $mynode;
104 $users{$call} = $self;
111 $self->delcluster(); # out of the whole cluster table
112 delete $users{$self->{call}}; # out of the users table
117 return %users + 1; # + 1 for ME (naf eh!)
123 # NODE special routines
128 @ISA = qw(DXCluster);
135 my ($pkg, $call, $confmode, $here, $pcversion, $dxchan) = @_;
136 my $self = $pkg->alloc($call, $confmode, $here, $dxchan);
137 $self->{version} = $pcversion;
138 $nodes{$call} = $self;
145 my ($pkg, $call) = @_;
146 return $nodes{$call};
154 foreach $list (values(%nodes)) {
155 push @out, $list if $list->{pcversion};
163 my $call = $self->call;
165 DXUser->delete($call); # delete all the users one this node
166 delete $nodes{$call};
171 return %nodes + 1; # + 1 for ME!