NAME

SWISS::BaseClass


DESCRIPTION

This class is designed to impliment many of the properties that you expect in inheritance. All the housekeeping functions are defined in this module. See the notes on use for a description of how to make use of it.


Functions

new

Returns a new SWISS::BaseClass object.

rebless

Converts a base class into your class! Call as $self->rebless($class) where $self is a base class object. It returns $self, reblessed, with the correct member variables.

initialize

Override this in each derived class to provide class specific initialization. For example, initialize may put arrays into member variables that need them. You must provide an initialize function.

reformat

Some line objects are implementing "lazy writing". This means that on writing an entry, they are only reformatted if they have been modified. The method reformat forces an object to be reformatted even if its content has not been modified. This may be useful e.g. to make sure the current formatting rules are applied.

setEvidenceTags @array

Sets the evidence tags of the object to the list passed in @array.

addEvidenceTag string

Adds the evidence tag to the object.

deleteEvidenceTag string

Deletes the evidence tag from the object.

hasEvidenceTag string

returns true if the object has the evidence tag.

getEvidenceTags

returns the array of evidence tags of the object

Check4Clashes

This function checks your classes member variable list for clashes with any class that it inherits from (any class that can(_containsFields) returns true on!). If it detects that in any base class that any data members have been already defined, it dies with a listing of the variables already used.

It stops searching a root of an inheritance hierachy when it can find no baseclasses that support _containsFields. It will find all clashes in an entire inheritance tree.

So in the inheritance hierachy of

 SWISS::BaseClass -> A -> B -\
                             > E
 SWISS::BaseClass -> C -> D -/

where E is the most derived class, if E contains names that clash with A members and names that clash with B members, both the A and B member clashes will be reported.

If there were clashes with B and C, say, then again, all of the clashes would be reported.

_containsFields

This function is responsible for comparing a classes fields with the set in the calling package. This implimentation will work for cases where all of the classes that contribute fields are derived from SWISS::BaseClass. You may wish to make your own class fit this interface, so what follows is an interface API.

_containsFields assumes that the first argument is the package that it is being called in. The following arguments are taken to be a list of fields which to check are not found in members of the current package.

It should return either undef or a reference to an array of name clashes in the format package::variable. It should call it's self for each parental class that supports this function.

So it would look something like _containsFields { my $class = shift; my @toCheck = @_;

    foreach @toCheck {
      check that they are not in me.  If they are, add them to the list of clashes to return.
    }
    add all base class clashes to your list of clashes
    if there were name clashes return a reference to them
    otherwise return undef
  }
equal

If two objects are equal, it returns true.

Warning: This funktion compares two objects using a simple dump in Perl format, see Data::Dumper module. The comparison also takes private variables into account. Therefore: If the method 'equal' returns true, the objects are guaranteed to be equal, but it might return false although the two objects are equal in they public attributes.

copy

Returns a "deep copy" of the object.


A skeletal derived class

 package myDerived;
 use vars qw ( @ISA %fields );
 BEGIN {
    @ISA = ('SWISS::BaseClass');
    %fields = (
               'i' => 1,
               'hash' => undef
               );

    myDerived->check4Clashes();
 }

 sub new {
    print "myDerived::new(@_)\n";
    my $class = shift;
    my $self = new SWISS::BaseClass;
    
    $self->rebless ($class);
    
    return $self;
 }

 sub initialize {
    my $self = shift;
    $self->{'hash'} = {};
 }

A class derived from myDerived would just substitute the name myDerived for SWISS::BaseClass. Hey presto - all sorted!