ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/ActiveDoc.pm
Revision: 1.5
Committed: Wed Sep 29 07:47:06 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.4: +1 -1 lines
Log Message:
Update for URLhandler namecahnges

File Contents

# User Rev Content
1 williamc 1.1 #
2     # The base functionality for the ActiveDocument - inherits from Basetags
3     #
4     # Inherits from BaseTags
5     # --------
6     # Interface
7     # ---------
8 williamc 1.2 # new(filename, DOChandler): create a new object based on a file and
9     # associate with a base DOChandler
10 williamc 1.1 # parse() : parse the input file
11     # include(url) : Activate include file mechanism, returns the object ref if OK
12     # treenode() : return the associated TreeNode object reference
13     # getincludeObjectStore : Return a pointer to the ObectStore that contains all
14     # included objects
15     # find(string) : find the object reference related to string in the associated
16     # tree. Mechanism for getting object references
17 williamc 1.2 # _addgroup() : Add group functionality to document
18     # parseerror(String) : Report an error to the user
19     # userinterface() : return the default User Interface object
20     # checktag($hashref, param , tagname) : Check a hash returned from switcher
21     # for a given parameter
22    
23     package ActiveDoc::ActiveDoc;
24     require 5.001;
25     use ActiveDoc::DOChandler;
26     use ActiveDoc::TreeNode;
27     use ActiveDoc::UserQuery;
28 williamc 1.1 use ObjectStoreCont;
29    
30 williamc 1.5 @ISA = qw(ActiveDoc::BaseTags);
31 williamc 1.1
32     # Initialise
33     sub _init {
34     my $self=shift;
35 williamc 1.2 my $DOChandler=shift;
36 williamc 1.1 my $OC=shift;
37    
38     $self->_addurl();
39 williamc 1.2 $self->{urlhandler}->setcache($DOChandler->defaultcache());
40     $self->{treenode}=ActiveDoc::TreeNode->new();
41     $self->{dochandler}=$DOChandler;
42     $self->{UserQuery}=$DOChandler->{UserQuery};
43     $self->{tags}->addtag("Use", \&Use_Start, "", "");
44 williamc 1.1 # Add the minimal functionality tag - feel free to override
45     $self->{tags}->addtag("Include", \&Include_Start, "", "");
46 williamc 1.2 $self->init();
47 williamc 1.1 }
48    
49 williamc 1.2 sub init {
50     # Dummy Routine - override for derrived classes
51     }
52 williamc 1.1 #
53 williamc 1.2 # use mechanism
54 williamc 1.1 #
55     sub include {
56     my $self=shift;
57     my $url=shift;
58 williamc 1.2 my $linkfile=shift;
59     my $filename;
60 williamc 1.1 my $obj;
61    
62 williamc 1.2 $file=$self->{urlhandler}->get($url);
63 williamc 1.4 if ( ( defined $linkfile) && ( $linkfile ne "" ) ) {
64 williamc 1.2 $filename=$file."/".$linkfile;
65 williamc 1.4 }
66     else {
67     $filename=$file;
68 williamc 1.2 }
69     $obj=$self->{dochandler}->newdoc($filename);
70    
71 williamc 1.1 # Now Extend our tree
72     $self->{treenode}->grow($obj->treenode());
73     return $obj;
74     }
75    
76 williamc 1.2 sub userinterface {
77     my $self=shift;
78     return $self->{dochandler}->{UserInterface};
79     }
80    
81 williamc 1.1 sub treenode {
82     my $self=shift;
83 williamc 1.2 return $self->{treenode};
84 williamc 1.1 }
85    
86     sub getincludeObjectStore {
87     my $self=shift;
88     return $self->{includeOS};
89     }
90    
91     sub find($) {
92     my $self=shift;
93     my $string=shift;
94 williamc 1.2 my $tn;
95 williamc 1.1
96 williamc 1.2 $tn=$self->{treenode}->find($string);
97     if ( $tn eq "" ) {
98     $self->parseerror("Unable to find $string");
99     }
100     return $tn->associate();
101     }
102    
103 williamc 1.3 sub line {
104     my $self=shift;
105     return $self->{switch}->line();
106     }
107    
108     sub error {
109     my $self=shift;
110     my $string=shift;
111    
112     die $string."\n";
113    
114     }
115 williamc 1.2 sub parseerror {
116     my $self=shift;
117     my $string=shift;
118    
119 williamc 1.3 print "Parse Error in $self->{url}, line ".
120     $self->line()."\n";
121 williamc 1.2 print $string."\n";
122     die;
123     }
124    
125     sub checktag {
126     my $self=shift;
127     my $hashref=shift;
128     my $param=shift;
129     my $tagname=shift;
130    
131     if ( ! exists $$hashref{$param} ) {
132     $self->parseerror("Incomplete Tag <$tagname> : $param required");
133     }
134 williamc 1.1 }
135    
136     # ------------------------ Tag Routines ------------------------------
137     #
138 williamc 1.2 # The Include tag
139 williamc 1.1 #
140 williamc 1.2
141 williamc 1.1 sub Include_Start {
142 williamc 1.2 my $self=shift;
143     my $name=shift;
144     my $hashref=shift;
145    
146     $self->{switch}->checkparam( $name, "ref");
147     print "<Include> tag not yet implemented\n";
148     # $self->include($$hashref{'ref'},$$hashref{'linkdoc'});
149 williamc 1.1 }
150    
151 williamc 1.2 sub Use_Start {
152     my $self=shift;
153 williamc 1.1 my $name=shift;
154     my $hashref=shift;
155    
156 williamc 1.2 print "<Use> tag not yet implemented\n";
157 williamc 1.1 }