annotate Lib/IMPL/Web/View/TTRegistry.pm @ 307:2da2564f115d

*TTView: fixed memory leak
author cin
date Thu, 18 Apr 2013 02:21:28 +0400
parents b5d5793f348e
children 5e4e7c8fbca1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
1 package IMPL::Web::View::TTRegistry;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
2 use strict;
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
3 use mro;
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
4
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
5 use IMPL::Const qw(:prop);
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
6 use IMPL::declare {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
7 require => {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
8 TTFactory => 'IMPL::Web::View::TTFactory'
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
9 },
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
10 base => [
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
11 'IMPL::Object' => undef,
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
12 'IMPL::Object::Disposable' => undef
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
13 ],
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
14 props => [
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
15 loader => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
16 context => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
17 _cache => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
18 ]
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
19 };
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
20
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
21 sub CTOR {
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
22 my ($this,$loader,$context) = @_;
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
23
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
24 $this->loader($loader);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
25 $this->context($context);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
26 $this->_cache({});
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
27 }
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
28
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
29 sub Require {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
30 my ($this,$name) = @_;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
31
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
32 if(my $factory = $this->_cache->{$name}) {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
33 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
34 } else {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
35 my $template = $this->loader->template($name)
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
36 or die AppException->new("Failed to load a template $name");
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
37
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
38 $factory = TTFactory->new(
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
39 $template,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
40 $this->context,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
41 $name,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
42 $this
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
43 );
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
44
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
45 $this->_cache->{$name} = $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
46 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
47 }
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
48 }
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
49
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
50 sub Dispose {
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
51 my ($this) = @_;
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
52
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
53 $this->_cache(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
54 $this->context(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
55 $this->loader(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
56
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
57 $this->next::method();
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
58 }
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
59
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
60 1;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
61
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
62 __END__
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
63
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
64 =pod
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
65
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
66 =head1 NAME
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
67
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
68 C<IMPL::Web::View::Registry> - реестр шаблонов документа.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
69
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
70 =head1 DESCRIPTION
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
71
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
72 Используется для реализации функции C<require> внутри шаблонов.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
73
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
74
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
75
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
76 =cut