annotate Lib/IMPL/Object.pm @ 276:8a5da17d7ef9

*IMPL::Class refactoring property definition mechanism (incomplete).
author sergey
date Thu, 31 Jan 2013 17:37:44 +0400
parents 6d8092d8ce1b
children 4ddb27ff4a0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
1 package IMPL::Object;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
3
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
4 use parent qw(IMPL::Object::Abstract);
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 180
diff changeset
5 require IMPL::Class::Property::Direct;
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
6 use IMPL::Const qw(:prop);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
8 sub surrogate {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
9 bless {}, ref $_[0] || $_[0];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
10 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
11
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
12 sub new {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
13 my $class = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
14 my $self = bless {}, ref($class) || $class;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
15 $self->callCTOR(@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
16
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
17 $self;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
18 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
20 sub _PropertyImplementor {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
21 'IMPL::Class::Property::Direct'
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
22 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
23
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
24 sub ImplementProperty {
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
25 my ($self,$name,$attributes) = @_;
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
26
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
27 $attributes = {
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
28 get => $attributes & PROP_GET,
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
29 set => $attributes & PROP_SET,
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
30 isList => $attributes & PROP_LIST
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
31 } unless ref $attributes;
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
32
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
33 $self->_ProppertyImplementor->Implement($name,$attributes);
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
34 }
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 230
diff changeset
35
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
36 1;
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
37
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
38 __END__
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
39
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
40 =pod
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
41
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 64
diff changeset
42 =head1 SINOPSYS
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
43
64
259cd3df6e53 Doc generation
wizard
parents: 53
diff changeset
44 =begin code
259cd3df6e53 Doc generation
wizard
parents: 53
diff changeset
45
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
46 package Foo;
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
47 use parent qw(IMPL::Object);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
48
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
49 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
50 my ($this,$arg) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
51 print "Foo: $arg\n";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
52 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
53
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
54 package Bar;
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
55 use parent qw(IMPL::Object);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
57 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
58 my ($this,$arg) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
59 print "Bar: $arg\n";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
60 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
61
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
62 package Baz;
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
63 use parent qw(Foo Bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
64
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
65 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
66 Foo => sub { my %args = @_; $args{Mazzi}; },
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
67 Bar => sub { my %args = @_; $args{Fugi}; }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
68 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
69
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
70 package Composite;
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
71 use parent qw(Baz Foo Bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
72
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
73 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
74 Foo => undef,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
75 Bar => undef
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
76 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
77
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
78 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
79 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
80
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
81 print "Composite: $args{Text}\n";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
82 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
83
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
84 package main;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
85
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
86 my $obj = new Composite(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
87 Text => 'Hello World!',
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
88 Mazzi => 'Mazzi',
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
89 Fugi => 'Fugi'
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
90 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
91
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
92 # will print
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
93 #
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
94 # Foo: Mazzi
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
95 # Bar: Fugi
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
96 # Bar:
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
97 # Composite: Hello World!
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
98
64
259cd3df6e53 Doc generation
wizard
parents: 53
diff changeset
99 =end code
259cd3df6e53 Doc generation
wizard
parents: 53
diff changeset
100
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
101 =head1 Description
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
102
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
103 Базовый класс для объектов, основанных на хеше.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
104
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
105 =head1 Members
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
106
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
107 =over
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
108
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
109 =item operator C<new>(@args)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
110
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
111 Создает экземпляр объекта и вызывает конструктор с параметрами @args.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
112
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
113 =item operator C<surrogate>()
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
114
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
115 Создает неинициализированный экземпляр объекта.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
116
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
117 =back
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
118
53
cf23fd8423f4 minor changes
wizard
parents: 49
diff changeset
119 =head1 Cavearts
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
120
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
121 Нужно заметить, что директива C<use parent> работает не совсем прозрачно, если в нашем примере
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
122 класс C<Composite> наследуется от C<Baz>, а затем C<Foo>, то наследование от
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
123 C<Foo> не произойдет поскольку он уже имеется в C<Baz>. Вот не задача:)
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
124
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 4
diff changeset
125 =cut