Wim Verhaegen > Math-LP > Math::LP::Object

Download:
Math-LP-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

Math::LP::Object - base class for objects in the Math::LP family

SYNOPSIS ^

    package Math::LP::Foo; # a new member Foo in the family

    # derive Foo from Object
    use Math::LP::Object;
    use base qw(Math::LP::Object);
    use fields qw(foo bar);

    sub initialize {
        my Math::LP::Foo $this = shift;
        # put Foo specific initialization code here
        # ...
        return 1;
    }

    # And add Foo-specific methods
    # ...

DESCRIPTION ^

Math::LP::Object provides the following methods to classes derived from it:

new()

Returns a new object, blessed in the package which it was called for. The returned object is a pseudo-hash, with fields specified using the fields pragma.

new() optionally accepts a hash of initial values of the data fields. After these values have been set, initialize() is called on the object. Specific initialization code for the derived class is thus to be put in the initialize() function of the derived class.

croak($msg)

Dies with an error message, adding info on the last caller outside the Math::LP family.

croak() can be invoked both as a method and a package function.

KNOWN PROBLEMS ^

The fields pragma is used here, which makes multiple inheritance impossible when other base classes also use the fields pragma (see fields). For this reason, Math::LP::LinearCombination and Math::LP::Variable are NOT derived from Math::LP::Object, and as a result have no access to the functionality the latter provides.

SEE ALSO ^

base, fields

AUTHOR ^

Wim Verhaegen <wimv@cpan.org>

COPYRIGHT ^

Copyright(c) 2000-2001 Wim Verhaegen. All rights reserved. This program is free software; you can redistribute and/or modify it under the same terms as Perl itself.

syntax highlighting: