GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::GOMOR::ARRAY (3)

.ds Aq ’

NAME

Class::Gomor::Array - class and object builder, array version

CONTENTS

SYNPOSIS



   # Create a base class in BaseClass.pm
   package My::BaseClass;

   require Class::Gomor::Array;
   our @ISA = qw(Class::Gomor::Array);

   our @AS = qw(attribute1 attribute2);
   our @AA = qw(attribute3 attribute4);
   our @AO = qw(other);

   # You should initialize yourself array attributes
   sub new { shift->SUPER::new(attribute3 => [], attribute4 => [], @_) }

   # Create indices and accessors
   My::BaseClass->cgBuildIndices;
   My::BaseClass->cgBuildAccessorsScalar(\@AS);
   My::BaseClass->cgBuildAccessorsArray(\@AA);

   sub other {
      my $self = shift;
      @_ ? $self->[$self->cgGetIndice(other)] = [ split(/\n/, shift) ]
         : @{$self->[$self->cgGetIndice(other)]};
   }

   1;

   # Create a subclass in SubClass.pm
   package My::SubClass;

   require My::BaseClass;
   our @ISA = qw(My::BaseClass);

   our @AS = qw(subclassAttribute);

   My::SubClass->cgBuildIndices;
   My::SubClass->cgBuildAccessorsScalar(\@AS);

   sub new {
      shift->SUPER::new(
         attribute1 => val1,
         attribute2 => val2,
         attribute3 => [ val3, ],
         attribute4 => [ val4, ],
         other      => [ none, ],
         subclassAttribute => subVal,
      );
   }

   1;

   # A program using those classes

   my $new = My::SubClass->new;

   my $val1     = $new->attribute1;
   my @values3  = $new->attribute3;
   my @otherOld = $new->other;

   $new->other("str1\nstr2\nstr3");
   my @otherNew = $new->other;
   print "@otherNew\n";

   $new->attribute2(newValue);
   $new->attribute4([ newVal1, newVal2, ]);



DESCRIPTION

This class is a subclass from <B>Class::GomorB>. It implements objects as array references, and inherits methods from <B>Class::GomorB>.

GLOBAL VARIABLES

See <B>Class::GomorB>.

METHODS

<B>newB> (hash) Object constructor. This is where user passed attributes (hash argument) are checked against valid attributes (gathered by <B>cgGetAttributesB> method). Valid attributes are those that exists (doh!), and have not an undef value. The default is to check this, you can avoid it by setting <B>B>$NoCheck<B>B> global variable (see perldoc <B>Class::GomorB>).
<B>cgBuildIndicesB> You MUST call this method one time at the beginning of your classes, and all subclasses (even if you do not add new attributes). It will build the matching between object attributes and their indices inside the array object. Global variables will be created in your class, with the following format: <B>B>$_<B>_attributeNameB>.
<B>cgBuildAccessorsScalarB> (array ref)
<B>cgBuildAccessorsArrayB> (array ref) See <B>Class::GomorB>.
<B>cgGetIndiceB> (scalar) Returns the array indice of specified attribute passed as a parameter. You can use it in your programs to avoid calling directly the global variable giving indice information concerning requesting object, thus avoiding using ‘no strictvars’;’. This method is usually used when you build your own accessors (those using attributes defined in <B>B>@AO<B>B>).
<B>cgCloneB> [ (scalar) ] You can clone one of your objects by calling this method. An optional parameter may be used to create multiple clones. Cloning will occure only on the first level attributes, that is, if you have attributes containing other objects, they will not be cloned.
<B>cgFullCloneB> [ (scalar) ] This method is the same as <B>cgCloneB>, but will clone all attributes recursively, but only if they are subclassed from <B>Class::GomorB>. So, objects created with other modules than <B>Class::Gomor::ArrayB> or <B>Class::Gomor::HashB> will not be cloned.

Another thing to note, there is no catch for cycling references (when you link two objects with each others). You have been warned.

<B>cgDumperB> Will return a string as with <B>Data::DumperB> Dumper method. This is useful for debugging purposes, because an arrayref object does not include attributes names.

SEE ALSO

Class::Gomor

AUTHOR

Patrice <GomoR> Auffret

COPYRIGHT AND LICENSE

Copyright (c) 2004-2015, Patrice <GomoR> Auffret

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::GOMOR::ARRAY (3) 2015-01-13

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.