Class-Maker

 view release on metacpan or  search on metacpan

lib/Class/Maker.pm  view on Meta::CPAN

	
		my $construct_list = isa_tree( @_ );
	
		my @ALL;
	
		foreach my $level ( sort { $b <=> $a } keys %$construct_list )
		{
			push @ALL, @{ $construct_list->{$level} };
		}
	
	return \@ALL;
	}

1;

__END__

=head1 NAME

Class::Maker - classes, reflection, schemas, serialization, attribute- and multiple inheritance

=head1 SYNOPSIS

  use Class::Maker qw(:all);

  class Something;

  class Person,
  {
     isa => [ 'Something' ],

     public =>
     {
       scalar => [qw( name age internal )],
     },

     private
     {
       int => [qw( internal )],
     },
  };

  sub Person::hello
  {
    my $this = shift;

    $this->_internal( 2123 ); # the private one

    printf "Here is %s and i am %d years old.\n",  $this->name, $this->age;
  };

  my $p = Person->new( name => Murat, age => 27 );

  $p->hello;


=head1 DESCRIPTION

This package is for everybody who wants to program oo-perl and does not really feel comfortable with the common way. Class::Maker introduces the concept of classes via a "class" function. It automatically creates packages, ISA, new and attribute-hand...

Reflection is transparently implemented and allows one to inspect the class properties and methods during runtime. This is  helpfull for implementing persistance and serialization. A Tangram (see cpan) schema generator is included to the package, so ...

=head1 INTRODUCTION

When you want to program oo-perl, mostly you suffer under the flexibility of perl. It is so flexibel, you have to do alot by hand. Here an example (slightly modified) from perltoot perl documentation for demonstration:

 package Person;

 @ISA = qw(Something);

 sub new {
    my $self  = {};
    $self->{NAME}   = undef;
    $self->{AGE}    = undef;
    bless($self);           # but see below
    return $self;
 }

 sub name {
    my $self = shift;
    if (@_) { $self->{NAME} = shift }
    return $self->{NAME};
 }

 sub age {
    my $self = shift;
    if (@_) { $self->{AGE} = shift }
    return $self->{AGE};
 }

C++ has really straightforward class decleration style. It looks really beautiful. At that time many cpan modules tried to compensate with perl idiom, i still rather missed something. This package though has a "class" function which transparetly decl...

 use Class::Maker qw(class);

 class 'Person',
 {
   isa => [ 'SomeBaseClass' ],

   public =>
   {
     scalar => [qw( name age )],
   },
 };

When using "class", you do not explictly need "package". The function does all symbol creation for you. It is more a class decleration (like in java/cpp/..). So here we now leap into the documentation.

=head1 FUNCTIONS

=head2 class()

The 'class' function is very central to Class::Maker. 

 class 'Class',
 {
   ..FIELDS..
 };

[Note] The parantheses for the class() function are optional.

Here 'Class' is the Name for the class. It is also the name for the package where the symbols for the class are created. Examples: 'Animal', 'Animal::Spider', 'Histology::Structures::Epithelia'.



( run in 0.811 second using v1.01-cache-2.11-cpan-39bf76dae61 )