Class::Generate

Class::Generate is a Perl module that can generate Perl class hierarchies.
Download

Class::Generate Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Steven Wartik
  • Publisher web site:
  • http://search.cpan.org/~swartik/Class-Generate-1.09/Generate.pod

Class::Generate Tags


Class::Generate Description

Class::Generate is a Perl module that can generate Perl class hierarchies. Class::Generate is a Perl module that can generate Perl class hierarchies.SYNOPSIS use Class::Generate qw(class subclass delete_class); # Declare class Class_Name, with the following types of members: class Class_Name => ; # Allocate an instance of class_name, with members initialized to the # given values (pass arrays and hashes using references). $obj = Class_Name->new ( s => scalar, a => , h => { key1 => v1, ... }, c => Class->new, c_a => , c_h => ); # Scalar type accessor: $obj->s($value); # Assign $value to member s. $member_value = $obj->s; # Access member's value. # (Class) Array type accessor: $obj->a(); # Assign whole array to member. $obj->a(2, $value); # Assign $value to array member 2. $obj->add_a($value); # Append $value to end of array. @a = $obj->a; # Access whole array. $ary_member_value = $obj->a(2); # Access array member 2. $s = $obj->a_size; # Return size of array. $value = $obj->last_a; # Return last element of array. # (Class) Hash type accessor: $obj->h({ k_1=>v1, ..., k_n=>v_n }) # Assign whole hash to member. $obj->h($key, $value); # Assign $value to hash member $key. %hash = $obj->h; # Access whole hash. $hash_member_value = $obj->h($key); # Access hash member value $key. $obj->delete_h($key); # Delete slot occupied by $key. @keys = $obj->h_keys; # Access keys of member h. @values = $obj->h_values; # Access values of member h. $another = $obj->copy; # Copy an object. if ( $obj->equals($another) ) { ... } # Test equality. subclass s => , -parent => 'class_name';The Class::Generate package exports functions that take as arguments a class specification and create from these specifications a Perl 5 class. The specification language allows many object-oriented constructs: typed members, inheritance, private members, required members, default values, object methods, class methods, class variables, and more.CPAN contains similar packages. Why another? Because object-oriented programming, especially in a dynamic language like Perl, is a complicated endeavor. I wanted a package that would work very hard to catch the errors you (well, I anyway) commonly make. I wanted a package that could help me enforce the contract of object-oriented programming. I also wanted it to get out of my way when I asked. Requirements: · Perl


Class::Generate Related Software