The various functions to be implemented are to be provided in the form of code_for_xxx()
perl functions. For better organization, these may be organized in several distinct perl modules. This is not a necessity, but it is at least good to know how this is supposed to work. We distinguish three types of files.
The elementary package files. These only have the mission of providing some code_for_xxx
functions. The MPFQ distribution contains some such packages, e.g. in Mpfq::defaults
. These files must be named with the extension .pm
, and abide by the following requirements.
begin with the proper package
statement. This statement must match the way the package is made reachable from perl
's includes. E.g. if the file is to be reached at the path some/where/pkg.pm
, then it should begin with package some::where::pkg;
.
Terminate with the 1;
statement to ensure a true value on package load.
Each elementary package file may include other package files of the same form. Such included packages are called parents of the current package. This mechanism resembles an object model's multiple inheritance schema, although MPFQ has chosen to divert from perl
's built-in MI mechanism. This is detailed later on.
We note that the set of code_for_xxx
functions provided by an elementary package file does not have to be complete in any way.
The top-level package file. This file is a wrap-up of several elementary package files. It typically includes many elementary package files, and as such, it obeys the same requirements as the package files themselves. The top-level package files does not absolutely need to rely of inclusion of several package files, as it is possible for all code_for_xxx
functions to appear directly at the top-level. The stuff which distinguishes the top-level package file from the more elementary ones is that it
must define a perl object, which inherits from Mpfq::engine::handler
. This is achieved by including the following statements in the code.
use Mpfq::engine::handler; our @ISA = qw/Mpfq::engine::handler/; sub new { return bless({}, shift); }
An additional requirement for the top-level package file is that the set of code_for_xxx
functions it (and its parents) provide has to be complete.
The generator file. This file mainly arranges so that the top-level package file gets created, and calls the appropriate functions. One of the tasks of the main generator file is also to setup the perl
include path properly (possibly relatively to the current file).