NAME

UNIVERSAL - Functions added to UNIVERSAL: every object derives from it


DESCRIPTION


 At the beginning of your code, write:
 require "UNIVERSAL.pl";
 This file defines 2 methods for the UNIVERSAL module: New and Clone.
 If object B derives from object A, inheritance "tree" looks like:
 
   UNIVERSAL     
       ^
       |
       |
    Object_A
       ^
       |
       |
    Object_B
    
 Then, Object_A and Object_B DO NOT define any constructor, they rather use the UNIVERSAL New method
 However, Object_A and Object_B could define a procedure named _Init, written as follows:
 
 sub _Init
 {
     my $self = shift;
     my @args = @_;
     my @super_args = ...;
     $self->SUPER::_Init(@super_args);
     ...    # More initialization
 }
 The method Clone lay be used to create a new object, initialized from the current object.
 WARNING !!! PLEASE DO NOT USE THIS METHOD if some attribute is a ref towards some other variable or object.
 
=cut

use strict; use warnings;

UNIVERSAL::New

 Title    : New
 Usage    : The constructor
 Access   : Public
 Function : The internal hash ($self) is created and blessed.
            The protected function _Init is then called, letting the derived classes
            to perform their own initialization
 Args     : the class, followed by object-specific arguments
 Returns  : The object
 Globals  : none

UNIVERSAL::Clone

 Title    : Clone
 Usage    : Clone (=copy) the object
 Access   : Public
 Function : A new hash is created and initialized from $self, and blessed
 Args     : none (-- or just the object)
 Returns  : The new object
 Globals  : none

UNIVERSAL::_Init

 Title    : _Init
 Usage    : Just to make the compiler happy in case the derived classes did not define _Init
 Access   : Protected
 Procedure: Does not do anything
 Args     : none
 Returns  : nothing
 Globals  : none