Mercurial > pub > Impl
diff Lib/IMPL/Class/Template.pm @ 165:76515373dac0
Added Class::Template,
Rewritten SQL::Schema
'use parent' directive instead of 'use base'
author | wizard |
---|---|
date | Sat, 23 Apr 2011 23:06:48 +0400 (2011-04-23) |
parents | |
children | d1676be8afcc |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/Class/Template.pm Sat Apr 23 23:06:48 2011 +0400 @@ -0,0 +1,113 @@ +package IMPL::Class::Template; +use strict; +use IMPL::lang; +use IMPL::_core::version; + +sub makeName { + my ($class,@params) = @_; + + $_ =~ s/^.*::(\w+)$/$1/ foreach @params; + return join('',$class,@params); +} + +1; + +__END__ + +=pod + +=head1 NAME + +C<IMPL::Class::Template> ������� ����� ��� ��������. + +=head1 SYNPOSIS + +=begin code + +package KeyValuePair; + +use IMPL::Class::Property; + +use IMPL::template ( + parameters => [qw(TKey TValue))], + base => [qw(IMPL::Object IMPL::Object::Autofill)], + declare => sub { + my ($class) = @_; + public $class->CreateProperty(key => prop_get | owner_set, { type => $class->TKey } ); + public $class->CreateProperty(value => prop_all, { type => $class->TValue} ); + + $class->PassThroughArgs; + } +); + +BEGIN { + public property id => prop_get | owner_set, { type => 'integer'}; +} + +__PACKAGE__->PassThroughArgs; + +package MyCollection; + +use IMPL::Class::Property; + +use IMPL::lang; +use IMPL::template( + parameters => [qw(TKey TValue)], + base => [qw(IMPL::Object)], + declare => sub { + my ($class) = @_; + my $item_t = spec KeyValuePair($class->TKey,$class->TValue); + + public $class->CreateProperty(items => prop_get | prop_list, { type => $item_t } ) + + $class->static_accessor( ItemType => $item_t ); + } +) + +sub Add { + my ($this,$key,$value) = @_; + + die new IMPL::ArgumentException( key => "Invalid argument type" ) unless is $key, $this->TKey; + die new IMPL::ArgumentException( value => "Invalid argument type" ) unless is $value, $this->TValue; + + $this->items->AddLast( $this->ItemType->new( key => $key, value => $value ) ); +} + +=end code + +=head1 DESCRIPTION + +������� ������������ ��� ������������ ��������� �������. ������� �������� ������ +�� ������� ���������� ��������������, ��� ���� ��������� ����� �����: + +=over + +=item 1 + +���������� ����� ����� � ������, ����������� �� ����� � ���������� ������� + +=item 2 + +����������� ������ C<@ISA> ��� ���������� ������, � ������� ����������� ��� ������� + +=item 3 + +����������� ������ � ������� ���������� �������, ������������ �������� �������� ���������� + +=item 4 + +���������� ����� ��� ��������������� ������������� + +=back + +=head1 MEMBERS + +=over + +=item C<spec(@params)> + +�����, ��������� ������������� �������. ����� ���� ������ ��� ��������. + +=back + +=cut \ No newline at end of file