annotate Lib/IMPL/Object.pm @ 2:78cd38551534

in develop
author Sergey
date Mon, 10 Aug 2009 17:39:08 +0400
parents 03e58a454b20
children e59f44f75f20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package IMPL::Object;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3
2
78cd38551534 in develop
Sergey
parents: 0
diff changeset
4 use base qw(IMPL::Object::Abstract);
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 sub surrogate {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 bless {}, ref $_[0] || $_[0];
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9
2
78cd38551534 in develop
Sergey
parents: 0
diff changeset
10 sub new {
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 my $class = shift;
2
78cd38551534 in develop
Sergey
parents: 0
diff changeset
12 my $self = bless {}, ref($class) || $class;
78cd38551534 in develop
Sergey
parents: 0
diff changeset
13 $self->callCTOR(@_);
78cd38551534 in develop
Sergey
parents: 0
diff changeset
14
78cd38551534 in develop
Sergey
parents: 0
diff changeset
15 $self;
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 =pod
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 =h1 SYNOPSIS
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 package Foo;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 use base qw(IMPL::Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 my ($this,$arg) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 print "Foo: $arg\n";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 package Bar;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 use base qw(IMPL::Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 my ($this,$arg) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 print "Bar: $arg\n";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 package Baz;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 use base qw(Foo Bar);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 our %CTOR = (
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 Foo => sub { my %args = @_; $args{Mazzi}; },
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 Bar => sub { my %args = @_; $args{Fugi}; }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45 package Composite;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 use base qw(Baz Foo Bar);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
47
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
48 our %CTOR = (
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
49 Foo => undef,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
50 Bar => undef
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
51 );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
52
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
53 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
54 my ($this,%args) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
55
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
56 print "Composite: $args{Text}\n";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
57 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
58
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
59 package main;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
60
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
61 my $obj = new Composite(
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
62 Text => 'Hello World!',
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
63 Mazzi => 'Mazzi',
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
64 Fugi => 'Fugi'
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
65 );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
66
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
67 # will print
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
68 #
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
69 # Foo: Mazzi
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
70 # Bar: Fugi
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
71 # Bar:
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
72 # Composite: Hello World!
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
73
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
74 =h1 Description
2
78cd38551534 in develop
Sergey
parents: 0
diff changeset
75 Áàçîâûé êëàññ äëÿ îáúåêòîâ, îñíîâàííûõ íà õåøå.
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
76
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
77 =h1 Members
2
78cd38551534 in develop
Sergey
parents: 0
diff changeset
78
78cd38551534 in develop
Sergey
parents: 0
diff changeset
79 =level 4
78cd38551534 in develop
Sergey
parents: 0
diff changeset
80
78cd38551534 in develop
Sergey
parents: 0
diff changeset
81 =item operator C<new>(@args)
78cd38551534 in develop
Sergey
parents: 0
diff changeset
82
78cd38551534 in develop
Sergey
parents: 0
diff changeset
83 Ñîçäàåò ýêçåìïëÿð îáúåêòà è âûçûâàåò êîíñòðóêòîð ñ ïàðàìåòðàìè @args.
78cd38551534 in develop
Sergey
parents: 0
diff changeset
84
78cd38551534 in develop
Sergey
parents: 0
diff changeset
85 =item operator C<surrogate>()
78cd38551534 in develop
Sergey
parents: 0
diff changeset
86
78cd38551534 in develop
Sergey
parents: 0
diff changeset
87 Ñîçäàåò íåèíèöèàëèçèðîâàííûé ýêçåìïëÿð îáúåêòà.
78cd38551534 in develop
Sergey
parents: 0
diff changeset
88
78cd38551534 in develop
Sergey
parents: 0
diff changeset
89 =back
78cd38551534 in develop
Sergey
parents: 0
diff changeset
90
78cd38551534 in develop
Sergey
parents: 0
diff changeset
91 =ð1 Cavearts
78cd38551534 in develop
Sergey
parents: 0
diff changeset
92
78cd38551534 in develop
Sergey
parents: 0
diff changeset
93 Íóæíî çàìåòèòü, ÷òî äèðåêòèâà C<use base> ðàáîòàåò íå ñîâñåì ïðîçðà÷íî, åñëè â íàøåì ïðèìåðå
78cd38551534 in develop
Sergey
parents: 0
diff changeset
94 êëàññ C<Composite> íàñëåäóåòñÿ îò C<Baz>, à çàòåì C<Foo>, òî íàñëåäîâàíèå îò
78cd38551534 in develop
Sergey
parents: 0
diff changeset
95 C<Foo> íå ïðîèçîéäåò ïîñêîëüêó îí óæå èìååòñÿ â C<Baz>. Âîò íå çàäà÷à:)
78cd38551534 in develop
Sergey
parents: 0
diff changeset
96
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
97 =cut
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
98
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
99 1;