serialization and initialization of tk objects

From: Brian Denheyer <briand_at_deldotd.com>
Date: Fri, 2 Jul 1999 11:00:55 -0700 (PDT)

This is long ( its length is proportional to my confusion).

I have been doing a lot of work lately with some serializing routines
which I received from the "unknown serializing code contributor".

The current implementation uses a saveable meta-class which requires
saveable slots to use a :saveable #t keyword

Naturally if you are trying to write out a tk object I need to
introduce this keyword somehow. Is there anyway to do this without
editing the widgets sources to include the saveable flag ?

I guess the obvious answer to this problem is to introduce a way to
specifically supply a list of slots to be saved. This seems like a
cleaner approach but I can't figure out how to cleanly implement it
using the meta-class approach.

(define-class <ioclass> (<class>)
  (saveable))

(define-class <saveable> ()
  ()
  :metaclass <ioclass>)

Saveable objects inherit <saveable> and then the initializer for
<ioclass> computes a list of saveable slots by looking for the
saveable keyword. It seems as though I might be able to introduce a
slot which is initialized with a list of the slots to be saved. The
<ioclass> initializer can use that slot to obtain the list. Does this
sound reasonable ??

Does anyone know if using a meta-class is really the right way to do
this ? I keep thinking that a mix-in approach would also be suitable.

Here is a related problem situation which I have run into and would
like some advice about :

<inh-canvas> <- <canvas>

<container>
  slotA : <inh-canvas> :parent <container>

Writing such an instance is not problem. Restoring it is a big
problem.

 <inh-canvas> requires that :parent be specified when the instance is
created. What I need is the ability to create an "empty" instance of
the <inh-canvas> widget so that the reader can update the parent later
during the readback process. I haven't been able to figure out a way
to do this.

What I would really like to see eventually with this code is the
ability to serialize Tk objects and then read them back in. This
seems like a VERY useful feature. It might require changes to the Tk
classes to support the serialization meta-class. Would such a change
be acceptable ??

The code works very well for objects which do not use tk-objects. I
am trying to understand if there is a good way to extend it to
tk-objects. Does anyone know of any books/web spots/ etc... which
discuss seralizing/marshalling... ?? I am sure that I am trying to
figure out things which have already been done, and I desperately want
to cheat. I did start with working code which helps considerably :-)


Brian
Received on Fri Jul 02 1999 - 20:02:10 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST