ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/TreeNode.pm
Revision: 1.1
Committed: Wed Aug 18 15:38:29 1999 UTC (25 years, 9 months ago) by williamc
Content type: text/plain
Branch: MAIN
Log Message:
New Tree Functionality

File Contents

# User Rev Content
1 williamc 1.1 #
2     # TreeNode - associate an object to a tree node in order to link it in
3     # to a searchable tree like structure
4     #
5     # Interface
6     # -----------
7     # new(name) : The name is just a plain string
8     # setparent(parentnode) : Set the parent node
9     # getparent() : return the parent node
10     # grow(node) : grow a new node extending from this node
11     # nodeList() : return a list of attatched nodes
12     # setassociate(Object) : Associate node with an object reference
13     # associate() : return the associated object reference
14     # find(string) : return the tree node that matches the search string
15     # within the current tree
16     # name() : return the name of the object
17    
18     package TreeNode;
19    
20     sub new {
21     my $class=shift;
22     my $name=shift;
23     $self={};
24     bless $self, $class;
25     $self->{name}=$name;
26     $self->{nodelist}=List->(new);
27     $self->{monkey}=TreeMonkey->new();
28     $self->{parent}="";
29     return $self;
30     }
31    
32     sub setparent() {
33     my $self=shift;
34     $self->{parent}=shift;
35     }
36    
37     sub getparent() {
38     my $self=shift;
39     return $self->{parent};
40     }
41    
42     sub grow {
43     my $self=shift;
44     my $node=shift;
45    
46     $self->{nodelist}->add($node);
47     }
48    
49     sub nodeList {
50     my $self=shift;
51     return $self->{nodelist}
52     }
53    
54     sub associate {
55     my $self=shift;
56     return $self->{associate};
57     }
58    
59     sub setassociate {
60     my $self=shift;
61     $self->{associate}=shift;
62     }
63    
64     #
65     # find -
66     #
67     sub find {
68     my $self=shift;
69     my $string=shift;
70    
71     # get our tree monkey to do the job
72     $self-{monkey}->goto($self); #start at this node
73     $self->{monkey>->find{$string};
74     }