Next: , Previous: eieio-singleton, Up: Base Classes

12.4 eieio-persistent

This class is defined in the package eieio-base.

If you want an object, or set of objects to be persistent, meaning the slot values are important to keep saved between sessions, then you will want your top level object to inherit from eieio-persistent.

To make sure your persistent object can be moved, make sure all file names stored to disk are made relative with eieio-persistent-path-relative.

— Class: eieio-persistent file file-header-line

Enables persistence for instances of this class. Slot file with initarg :file is the file name in which this object will be saved. Class allocated slot file-header-line is used with method object-write as a header comment.

All objects can write themselves to a file, but persistent objects have several additional methods that aid in maintaining them.

— Method on eieio-persistent: eieio-persistent-save obj &optional file

Write the object obj to its file. If optional argument file is specified, use that file name instead.

— Method on eieio-persistent: eieio-persistent-path-relative obj file

Return a file name derived from file which is relative to the stored location of OBJ. This method should be used to convert file names so that they are relative to the save file, making any system of files movable from one location to another.

— Method on eieio-persistent: object-write obj &optional comment

Like object-write for standard-object, but will derive a header line comment from the class allocated slot if one is not provided.

— Function: eieio-persistent-read filename &optional class allow-subclass

Read a persistent object from filename, and return it. Signal an error if the object in FILENAME is not a constructor for CLASS. Optional allow-subclass says that it is ok for eieio-persistent-read to load in subclasses of class instead of being pedantic.