NAME
Class::Tom - Transportable Object model for Perl
DESCRIPTION
Tom allows for distributed perl objects. It does not require that an object's class exists on the machine in order for the object to be used.
SYNOPSIS
use Class::Tom qw ( repair );
my $tom = new Class::Tom Class => 'Demo';
$tom->declare(Name => 'new', Code => '{
my $class = shift;
my $self = {};
bless $self, $class;
}');
$tom->declare(Name => 'setname', Code => '{
my $self = shift;
$self->{name} = shift;
}');
$tom->register();
my $obj = new Demo;
$obj->setname('james duncan');
$tom->insert($obj);
$data = $tom->store();
print $data;
my $newtom = repair($data);
$tom->cleanup();
new
new
creates a new object of the TOM class. This is your container for any module. It accepts only one argument, and that is the class that the container will hold.
class
class
returns the class name of the object.
checksum
checksum
returns the MD5 checksum of a TOM container.
insert
insert
takes one argument - the object that you wish to make transportable. If there are no methods for the the object you insert, Tom will try to find the .pm file that corresponds to that particular object. If it is able to, then it also attempts to compile all the methods in that class into the Tom object.
Tom
now allows you to insert more than one object of the same class.
declare
declare
lets you add functions to the class that will be stored inside the container. It accepts two arguments Name, which is the name of the function, and Code which contains the code that the function uses.
Declaring a function inside the container also declares it outside the container, allowing you to create the object at the same time, without having to call register
in order to do so.
register
register
takes a TOM container, and allows its methods to be accessible from within Perl. If an object exists within the container, register
will return the object.
If register
is called with the Compartment variable specified then all of Tom's registering takes place within the safe compartment referenced by the Compartment variable.
In addition, if there is an 'import' subroutine declared within the class, Tom will execute the code stored within as soon as it has registered the functions.
If more than one object exists within the container, and register is called in array context then register
returns an array of un-eval'd objects. In order to use any of these objects, they need to be eval'ed.
In scalar context register
returns a fully working object, that corresponds to the first object that was inserted into the array.
get_object
get_object
returns the object stored within the container, but doesn't register the class on the local machine, which will cause problems unless you have already used the register
method.
store
store
returns a transportable version of the TOM container. It no longer cleans the namespace before continuing.
repair
repair
takes one argument. This argument is a TOM container that has been store
'ed. It returns a Perl object that is the TOM container.
debug
debug
sets the debug level for TOM. Used for development.
cleanup
cleanup
deletes the functions registered from the TOM container into a namespace, preventing problems in the case of TOM execution servers.
methods
methods
returns a LIST of the functions inside the TOM container.
NIGGLY BITS (or BUGS)
Fix'em as I get 'em.
MAILING LIST
A mailing list has been set up for Tom and other perl-related Agent projects, called Perl5-Agents. The request address for this mailing list is perl5-agents-request@daft.com. To send mail to the list email perl5-agents@daft.com.
SEE ALSO
perl(1), perlobj(1)
AUTHOR
James Duncan <jduncan@hawk.igs.net>
KUDOS
Thanks to the following people for help with various things: (Many Bug Reports) Mike Blakely <mikeb@netscape.com> (Many suggestions) Steve Purkis <spurkis@engsoc.carleton.ca> (P5A Mailing list) Darran Stalder <torin@daft.com>