view Lib/IMPL/Object.pm @ 120:41e9d9ea3db5

Merge with 79cdd6c86409806bd1de092d9f0fb2b048775720
author wizard
date Mon, 07 Jun 2010 17:45:14 +0400 (2010-06-07)
parents 259cd3df6e53
children e6447ad85cb4
line wrap: on
line source
package IMPL::Object;
use strict;

use base qw(IMPL::Object::Abstract);

sub surrogate {
    bless {}, ref $_[0] || $_[0];
}

sub new {
    my $class = shift;
    my $self = bless {}, ref($class) || $class;    
    $self->callCTOR(@_);
  
    $self;
}

sub _PropertyImplementor {
    'IMPL::Class::Property::Direct'
}

1;

__END__

=pod

=head1 SYNOPSIS

=begin code

package Foo;
use base qw(IMPL::Object);

sub CTOR {
    my ($this,$arg) = @_;
    print "Foo: $arg\n";
}

package Bar;
use base qw(IMPL::Object);

sub CTOR {
    my ($this,$arg) = @_;
    print "Bar: $arg\n";
}

package Baz;
use base qw(Foo Bar);

our %CTOR = (
    Foo => sub { my %args = @_; $args{Mazzi}; },
    Bar => sub { my %args = @_; $args{Fugi}; }
);

package Composite;
use base qw(Baz Foo Bar);

our %CTOR = (
    Foo => undef,
    Bar => undef
);

sub CTOR {
    my ($this,%args) = @_;
    
    print "Composite: $args{Text}\n";
}

package main;

my $obj = new Composite(
    Text => 'Hello World!',
    Mazzi => 'Mazzi',
    Fugi => 'Fugi'
);

# will print
#
# Foo: Mazzi
# Bar: Fugi
# Bar:
# Composite: Hello World!

=end code

=head1 Description

������� ����� ��� ��������, ���������� �� ����.

=head1 Members

=over

=item operator C<new>(@args)

������� ��������� ������� � �������� ����������� � ����������� @args.

=item operator C<surrogate>()

������� �������������������� ��������� �������.

=back

=head1 Cavearts

����� ��������, ��� ��������� C<use base> �������� �� ������ ���������, ���� � ����� �������
����� C<Composite> ����������� �� C<Baz>, � ����� C<Foo>, �� ������������ ��
C<Foo> �� ���������� ��������� �� ��� ������� � C<Baz>. ��� �� ������:)

=cut