home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_96bb312e06a04233b4bc507ab09893df
< prev
next >
Wrap
Text File
|
2000-03-23
|
6KB
|
146 lines
<HTML>
<HEAD>
<TITLE>Eroot - an eternal root to handle persistent objects</TITLE>
<LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> Eroot - an eternal root to handle persistent objects</P></STRONG>
</TD></TR>
</TABLE>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
<LI><A HREF="#abstract">ABSTRACT</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#instance variables">INSTANCE VARIABLES</A></LI>
<LI><A HREF="#things to avoid">THINGS TO AVOID</A></LI>
<LI><A HREF="#notes">NOTES</A></LI>
<LI><A HREF="#files">FILES</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Eroot - an eternal root to handle persistent objects</P>
<P>
<HR>
<H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
<UL>
<LI>Linux</LI>
<LI>Solaris</LI>
<LI>Windows</LI>
</UL>
<HR>
<H1><A NAME="abstract">ABSTRACT</A></H1>
<P>The Eternal Root (eroot) is given references to the root objects of any
object hierarchies which must persist between separate invocations of the
application. When the eroot's destructor is called, the eroot will find all
objects referenced in the object hierarchies and will store them. All
objects will be restored (if possible) when and if the <STRONG>Continue</STRONG> message
is sent to the eroot.</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
require Class::Eroot;
my $some_obj;
my $eroot = new EROOT ( 'Name' => "persist.file",
'Key' => "myAppObjects" );</PRE>
<PRE>
if( $eroot->Continue ){
# No existing objects. Start from scratch.
$some_obj = new SomeObj;
$eroot->Keep( "Some_obj" => $some_obj );
}
else{
$some_obj = $eroot->Root("some_obj");
}</PRE>
<PRE>
$eroot->List;
$eroot->Keep( "MyObj" => $myobj );
$eroot->Lose( "Old_Obj" );
$eroot->Lose( $this_obj );</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>When the eroot saves a group of object hierarchies, it stores its <STRONG>key</STRONG>
with them. The key of any objects being restored must match the key of the
eroot which is trying to restore them. The <STRONG>Continue</STRONG> method will call
<STRONG>die</STRONG> if the keys do not match. Continue will return 0 if the objects were
loaded and non-zero if they were not.</P>
<P>The eroot will attempt to send a <STRONG>suspend</STRONG> message to the object prior to
storing the object's state. The object's class is not required to have a
suspend method defined.</P>
<P>When the eroot restores an object it will bless the object reference in the
object's class (package) and will attempt to send a <STRONG>resume</STRONG> message to the
object. The object's class is not required to have a resume method defined.</P>
<P>An object should not propagate <STRONG>suspend</STRONG> and <STRONG>resume</STRONG> messages. The eroot
will send suspend messages to the objects in the order in which they were
stored in the eroot (breadth-first, root-to-leaves). The eroot will send
resume messages by starting with the classes of the objects at the leaves of
the object hierarchy and moving toward the root of the object hierarchy.</P>
<P>Note that Perl will call the <STRONG>destructors</STRONG> of the persistent objects. The
programmer should be prepared to deal with this.</P>
<P>It is necessary to <STRONG>Keep</STRONG> an object only once. The object will remain
persistent until the eroot is told to <STRONG>Lose</STRONG> it.</P>
<P>
<HR>
<H1><A NAME="instance variables">INSTANCE VARIABLES</A></H1>
<P>References will be properly hooked up if they are type SCALAR, ARRAY, REF,
or HASH. The eroot assumes that keys and values (if the value is not a
reference) for the objects' <STRONG>instance variables</STRONG> can be represented as text
within single quotes. If this is not true for your objects then the object's
<STRONG>suspend</STRONG> method can be used to ``wrap'' the object for storage, and the
<STRONG>resume</STRONG> method can be used to ``unwrap'' the object.</P>
<P>Embedded single quotes in the value will be preserved. This is
currently the only place where single quotes are handled.</P>
<P>
<HR>
<H1><A NAME="things to avoid">THINGS TO AVOID</A></H1>
<PRE>
o Storing the eroot.
o Storing references to tie()'d variables and objects.
o Storing references to CODE objects.
o Storing the same object in two different eroots.
Unless you think you know what you're doing, of course.
o Using two eroots to store each other :)
o Storing named arrays and hashes. These will be restored as
anonymous arrays and hashes.
o Storing an object while it has an open stream.
o Storing an object which has an %OVERLOAD somewhere in
it's class hierarchy.</PRE>
<P>Know your object hierarchy. Be sure that everything in the hierarchy
can handle persistence.</P>
<P>
<HR>
<H1><A NAME="notes">NOTES</A></H1>
<P>This is not an OODBMS.</P>
<P>
<HR>
<H1><A NAME="files">FILES</A></H1>
<PRE>
Class::Eroot.pm - Eternal Root class.
persist.file - User-defined file where objects are stored.
Class::Template.pm - Struct/member template builder.</PRE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> Eroot - an eternal root to handle persistent objects</P></STRONG>
</TD></TR>
</TABLE>
</BODY>
</HTML>