line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MVC;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19707
|
use 5.006;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
57
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01.06';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $DEBUG = 0;
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
949
|
use Class::Maker qw(:all);
|
|
1
|
|
|
|
|
9821
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
852
|
use Class::Listener;
|
|
1
|
|
|
|
|
222
|
|
|
1
|
|
|
|
|
23
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
758
|
use Class::Observable;
|
|
1
|
|
|
|
|
5278
|
|
|
1
|
|
|
|
|
461
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# The Facade
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Class::Maker::class
|
20
|
|
|
|
|
|
|
{
|
21
|
|
|
|
|
|
|
public =>
|
22
|
|
|
|
|
|
|
{
|
23
|
|
|
|
|
|
|
ref => [qw( model view controller )],
|
24
|
|
|
|
|
|
|
},
|
25
|
|
|
|
|
|
|
};
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _preinit : method
|
28
|
|
|
|
|
|
|
{
|
29
|
0
|
|
|
0
|
|
|
my $this = shift;
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$this->controller( ( ref($this).'::Controller' )->new() );
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$this->model( ( ref($this).'::Model' )->new() );
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$this->view( ( ref($this).'::View' )->new() );
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _postinit : method
|
39
|
|
|
|
|
|
|
{
|
40
|
0
|
|
|
0
|
|
|
my $this = shift;
|
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$this->interconnect();
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub interconnect : method
|
46
|
|
|
|
|
|
|
{
|
47
|
0
|
|
|
0
|
0
|
|
my $this = shift;
|
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$this->view->model( $this->model ) if $this->model;
|
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
$this->view->controller( $this->controller ) if $this->controller;
|
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
$this->controller->model( $this->model ) if $this->model;
|
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
$this->controller->view( $this->view ) if $this->view;
|
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
$this->model->add_observer( $this->view ) if $this->view;
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package Class::MVC::Model;
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Class::Maker::class
|
63
|
|
|
|
|
|
|
{
|
64
|
|
|
|
|
|
|
isa => [qw( Class::Observable )],
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
};
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub DESTROY
|
69
|
|
|
|
|
|
|
{
|
70
|
0
|
|
|
0
|
|
|
my $this = shift;
|
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$this->delete_observers;
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package Class::MVC::View;
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Class::Maker::class
|
78
|
|
|
|
|
|
|
{
|
79
|
|
|
|
|
|
|
isa => [qw( Class::Listener )],
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
public =>
|
82
|
|
|
|
|
|
|
{
|
83
|
|
|
|
|
|
|
ref => [qw( controller model )],
|
84
|
|
|
|
|
|
|
},
|
85
|
|
|
|
|
|
|
};
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# dispatch method for Observer ( see Class::Observable )
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub update : method
|
90
|
|
|
|
|
|
|
{
|
91
|
0
|
|
|
0
|
|
|
my $this = shift;
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my ( $object, $action ) = @_;
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return $this->Class::Listener::signal( $action, $object );
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
package Class::MVC::CompositeView;
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Class::Maker::class
|
101
|
|
|
|
|
|
|
{
|
102
|
|
|
|
|
|
|
isa => [qw( Class::MVC::View )],
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
public =>
|
105
|
|
|
|
|
|
|
{
|
106
|
|
|
|
|
|
|
# The subView/superView relationship
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
ref => [qw( super_view )],
|
109
|
|
|
|
|
|
|
},
|
110
|
|
|
|
|
|
|
};
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# not implemented
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub sub_views : method
|
115
|
|
|
|
|
|
|
{
|
116
|
0
|
|
|
0
|
|
|
my $this = shift;
|
117
|
|
|
|
|
|
|
}
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub update : method
|
120
|
|
|
|
|
|
|
{
|
121
|
0
|
|
|
0
|
|
|
my $this = shift;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# update yourself
|
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$this->SUPER::update( @_ );
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# and your superviews
|
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
$this->super_view->update( @_ ) if $this->super_view;
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
package Class::MVC::Controller;
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Class::Maker::class
|
135
|
|
|
|
|
|
|
{
|
136
|
|
|
|
|
|
|
public =>
|
137
|
|
|
|
|
|
|
{
|
138
|
|
|
|
|
|
|
ref => [qw( model view )],
|
139
|
|
|
|
|
|
|
},
|
140
|
|
|
|
|
|
|
};
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub _postinit : method
|
143
|
|
|
|
|
|
|
{
|
144
|
0
|
|
|
0
|
|
|
my $this = shift;
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub update_model : method
|
148
|
|
|
|
|
|
|
{
|
149
|
0
|
|
|
0
|
|
|
my $this = shift;
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# call Model methods from here
|
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
$this->model->Class::Listener::signal( 'update', $this, @_ );
|
154
|
|
|
|
|
|
|
}
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub change_view : method
|
157
|
|
|
|
|
|
|
{
|
158
|
0
|
|
|
0
|
|
|
my $this = shift;
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# call View methods from here
|
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
$this->view->Class::Listener::signal( 'change', $this, @_ );
|
163
|
|
|
|
|
|
|
}
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1;
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
__END__
|