SourceForge Logo

NAME

Data::Propertiable - A way to create read/write attributs and associated methods

SYNOPSIS

  package MyClass;

  use base qw( MyMotherClass );
  use Data::Propertiable qw( attribut1 attribut2 );
  #  # Or :
  #  use Data::Propertiable qw( attribut1 attribut2 );
  #  use base qw( MyMotherClass Data::Propertiable );

  sub new {
    ...
  }

  ...

  package main;

  my $myclass=new MyClass;
  $myclass->attribut1(7);  
  $myclass->attribut2([2,5,6]);
  print $myclass->attribut1;       # print 7;
  print $myclass->attribut2->[1];  # print 5;

DESCRIPTION

This class implement a way to auto-create read methods and write methods.

You just have to call a use with the attributs name, and then to inherit your class from this class.

The read and write methods are auto-created at the first call if fail. That mean you can ``override'' them.

This has been report to be like the property in C++ Builder, Delphi or VB.

Note that such attributs are consided as public in the GISSUML Model.

  +  attribut1
  +  attribut2

Mean in fact:
  -  attribut1
  -  attribut2
  +  attribut1 () : SCALAR
  +  attribut1 ( : SCALAR ) : SCALAR
  +  attribut2 () : SCALAR
  +  attribut2 ( : SCALAR ) : SCALAR

Note also that the return value for ``+ attribut2 ( : SCALAR ) : SCALAR'' is in fact the last value and not the new.

GISSUML MODEL

 -$ properties () : Hash
 -  is_a_property ( attribut : SCALAR ) : Array
 -$ is_a_property ( attribut : SCALAR ) : Array
 -  AUTOLOAD ( ... ) :
 -$ import () :

properties

 -$ properties () : Hash

This static class acces to the static attribut that contains all the autoloaded attributs. The attribut is a reference on a HASH which keys are the attribut's names.

is_a_property

 -  is_a_property ( attribut : SCALAR ) : Array
 -$ is_a_property ( attribut : SCALAR ) : Array

This method (that can be used as static one) return undef if the attribut is not autoloaded.

If the attribut is, it return a reference on an array that contain the class where it should be loaded.

AUTOLOAD

 -  AUTOLOAD ( ... ) :

This method is called by perl each time a method is not found for an instance (or a class). This method die if no autoloaded attribut can be found, or create the method and then goto it...

import

 -$ import () :

This static method is called by perl each time a use Data::Propertiable is called with arguments.

AUTHORS

This class was written by Arthibus Gissehel <gissehel@vachefolle.com> in 2000.

NOTES

This class is part of the Boucherot project.