ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/TreeNode.pm
Revision: 1.3
Committed: Mon Sep 20 16:27:58 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: ProtoEnd
Changes since 1.2: +3 -3 lines
Log Message:
Basic Working Level

File Contents

# Content
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 # parent() : 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 ActiveDoc::TreeNode;
19 require 5.001;
20 use ActiveDoc::TreeMonkey;
21 use Utilities::List;
22
23 sub new {
24 my $class=shift;
25 my $name=shift;
26 $self={};
27 bless $self, $class;
28 $self->{name}=$name;
29 $self->{nodelist}=Utilities::List->new();
30 $self->{monkey}=ActiveDoc::TreeMonkey->new();
31 $self->{parent}="/";
32 return $self;
33 }
34
35 sub setparent() {
36 my $self=shift;
37 $self->{parent}=shift;
38 }
39
40 sub parent() {
41 my $self=shift;
42 return $self->{parent};
43 }
44
45 sub grow {
46 my $self=shift;
47 my $node=shift;
48
49 $self->{nodelist}->add($node);
50 }
51
52 sub nodeList {
53 my $self=shift;
54 return $self->{nodelist};
55 }
56
57 sub associate {
58 my $self=shift;
59 return $self->{associate};
60 }
61
62 sub setassociate {
63 my $self=shift;
64 $self->{associate}=shift;
65 }
66
67 sub name {
68 my $self=shift;
69 return $self->{name};
70 }
71
72 #
73 # find -
74 #
75 sub find {
76 my $self=shift;
77 my $string=shift;
78
79 # get our tree monkey to do the job
80 $self->{monkey}->goto($self); #start at this node
81 $self->{monkey}->find($string);
82 }