Revision 3 (by ahitrov@rambler.ru, 2010/03/24 15:19:32) |
The CORE
|
package @NAME@::State;
# ----------------------------------------------------------------------------
# ��������� ������� @NAME@.
# � ���� ������ ����������� ������ ���� ������ new(), info().
#
# ��� �������� ������� Contenido::State ����� ������ ����� ������
# ������ @NAME@::State. �� ����� �������� (���� ����� ������ ������)
# ����� �����, ������� ��� ������ ���������� ���������� ����������
# ��������� perl-����: lc('@NAME@').
# ----------------------------------------------------------------------------
use strict;
use vars qw($VERSION $AUTOLOAD);
$VERSION = '1.0';
sub new {
my ($proto) = @_;
my $class = ref($proto) || $proto;
my $self = {};
bless($self, $class);
## ����� ��������� ������� �� ������ ���������� �� config.mk � ����:
## $self->{variable_name} = 'VARIABLE_NAME_SURROUNDED_BY_@@';
$self->{contenido_notab} = 1;
$self->_init_();
return $self;
}
# ����� ���������� �� �������...
sub info
{
my $self = shift;
return undef unless ref($self);
warn "Contenido: ������ @NAME@::State �������� ���������� �����������:\n";
foreach my $attribute (sort (keys( %{ $self->{attributes} } )))
{
my $la = length($attribute);
warn "\t".$attribute.("\t" x (2-int($la/8))).": ".$self->{$attribute}."\n";
}
}
# �������������.
# - ������� ������ ������� ��� � ������ ����� - ��� ����� ��� �������
# ������ ������ AUTOLOAD...
sub _init_
{
my $self = shift;
## ����� ������ ����������, ��������� � new()
foreach my $attribute ( qw(
contenido_notab
) )
{
$self->{attributes}->{ $attribute } = 'SCALAR';
}
}
# ----------------------------------------------------------------------------
# ��� ����� AUTOLOAD. ����� ������� ��� ���������/������ �����...
# ������ 0.2
# ----------------------------------------------------------------------------
sub AUTOLOAD
{
my $self = shift;
my $attribute = $AUTOLOAD;
$attribute =~ s/.*:://;
return undef unless $attribute =~ /[^A-Z]/; # ��������� ������ ���� DESTROY
if (! exists($self->{attributes}->{$attribute}))
{
warn "Contenido Error (@NAME@::State): ����� ������, ��� �������� �� ���������� ��������������� ��������: ->$attribute()\n";
return undef;
}
$self->{ $attribute } = shift @_ if (scalar(@_) > 0);
return $self->{ $attribute };
}
1;