ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Application.pm
Revision: 1.2
Committed: Thu Jan 27 17:50:38 2000 UTC (25 years, 3 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +18 -2 lines
Log Message:
Many mods for BootStrapping

File Contents

# Content
1 #
2 # Application.pm
3 #
4 # Originally Written by Christopher Williams
5 #
6 # Description
7 # -----------
8 # Sets up the basic Activedoc Structure - and provides applications with
9 # facilities to BootStrap an activedoc
10 #
11 # Interface
12 # ---------
13 # new(store,query) : A new Application object
14 # activatedoc(url[,options]) : return the oref of a doc corresponding
15 # to the url
16 # userinterface([IntObj]) : set/get user interface object - defaults
17 # to SimpleUserInterface if not overridden
18 # store() : return the store
19 # newdoc(type) : Instantiate a new ActiveDoc
20 # object of the specified type
21 # find(@keys) : find an object in the activedoc objectdb
22
23 package ActiveDoc::Application;
24 require 5.004;
25 use ActiveDoc::SimpleUserInterface;
26
27 sub new {
28 my $class=shift;
29 $self={};
30 bless $self, $class;
31 $self->{store}=shift;
32 $self->{options}=shift;
33
34 # make sure data is empty
35 undef $self->{StarterDoc};
36 undef $self->{UI};
37
38 $self->_initdoc();
39 return $self;
40 }
41
42 sub store {
43 my $self=shift;
44 return $self->{store};
45 }
46
47 sub find {
48 my $self=shift;
49 return ($self->{store}->find(@_));
50 }
51
52 sub userinterface {
53 my $self=shift;
54
55 if ( @_ ) {
56 $self->{UI}=shift;
57 }
58 elsif ( ! defined $self->{UI} ) {
59 $self->{UI}=ActiveDoc::SimpleUserInterface->new();
60 }
61 return $self->{UI};
62 }
63
64 sub activatedoc {
65 my $self=shift;
66 my $url=shift;
67
68 # Create a new document
69 return $self->{StarterDoc}->activatedoc($url);
70 }
71
72 sub options {
73 my $self=shift;
74
75 if ( @_ ) {
76 $self->{options}=shift;
77 }
78 else {
79 (defined $self->{options})?$self->{options}:undef;
80 }
81 }
82
83 sub newdoc {
84 my $self=shift;
85 my $type=shift;
86
87 return $type->new($self->{store},$self->{StarterDoc});
88 }
89
90 # ---------------- private methods
91 sub _initdoc {
92 my $self=shift;
93
94 if ( ! defined $self->{StarterDoc} ) {
95 $self->{StarterDoc}=ActiveDoc::StarterDoc->new($self->{store},
96 $self->userinterface(),$self->options());
97 }
98 }
99