Documentation | SupportKit | Archivable
SYNOPSIS
Perl
use HaikuR1::Archivable; # define MyArchivable subclass here my $archivable = MyArchivable->new(); my $archive = $flattenable->Archive(); my $unarchived = MyArchivable->new($archive); # or my $unarchived = Archivable::instantiate_object($archive);
Python
from HaikuR1.SupportKit import Archivable # define MyArchivable subclass here archivable = MyArchivable() archive = flattenable.Archive() unarchived = MyArchivable(archive) # or unarchived = Archivable.instantiate_object(archive)
DESCRIPTION
Exposes the BArchivable
object.
For more information on Archivable, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates an Archivable.
Perl
my $archivable = HaikuR1::Archivable->new($archive);
Python
archivable = Archivable(archive)
archive
Optional; a Message containing an archived version of the Archivable. If present, the object will be reconstituted from the archive. A plain Archivable object isn't much use, since it doesn't store anything but the class name. However, this base constructor should be called from subclass constructors.
Perl
package MyArchivable; our @ISA = qw(HaikuR1::Archivable); sub new { my $class = shift; my $self = $class->SUPER::new(@_); # etc... return $self; }
Python
class MyArchivable(Archivable): def __init__(self, msg=None): Archivable.__init__(self, msg) # etc...
Archive
Stores the Archivable to a Message. Returns the Message or signals an error.
Archive
may also be called as a hook; for example, when a Window is
archived, its child Views may be archived with it.
Perl
my $archive = $archivable->Archive($deep);
Python
archive = archivable.Archive(deep)
deep
Optional; a boolean, if true, the archive will include objects that belong to the Archivable. ("Belong" is defined by each class; the Archivable class itself does nothing with this parameter, but Window includes child views if
deep
is true.) Defaults to false.
After storing your own information, you should call the base class version.
HOOKS
AllArchived
Called when an Archiver has completely archived the object and any contained archives. May signal an error.
Perl
$archivable->AllArchived($archive);
Python
archivable.AllArchived(archive)
archive
A Message, the target the object was archived into.
AllUnarchived
Called when an Unarchiver has completely unarchived the object and any contained archives. May signal an error.
Perl
$archivable->AllUnarchived($archive);
Python
archivable.AllUnarchived(archive)
archive
A Message, the Message the object was unarchived from.
FUNCTIONS
instantiate_object
Called to instantiate an object whose class is unknown. (For example, if you have an archived View, but you're not sure whether it's a Button or a StringView, or some other subclass.) Returns the unarchived object.
Perl
my $unarchived = HaikuR1::Archivable::instantiate_object($from);
Python
unarchived = Archivable.instantiate_object(from)
from
A Message containing an archived version of the Archivable.