story.dbcore.attributes
Interface InternableObject
- All Known Subinterfaces:
- AssignedPredicateAddress
- All Known Implementing Classes:
- AssignedAction, AssignedActionAddress, AssignedConditionAddress, AssignedModifier, AssignedModifierAddress, InterpNodeID, NamedNoun, NodeProxy, ValidAction, ValidCondition, ValidModifier, ValidNoun
public interface InternableObject
An interface which allows DBCore to intern and unintern objects
from other modules it doesn't know about.
"Interning" means making a copy of the object where any referents
are deferenced and made static. This is done to make a memento
that deals in addresses rather than objects -- we don't want to
refer to an object that will be missing if we undo and then redo
the command.
Specific motivating example: NodeProxies are used to let
propositions refer to one another in a way that updates "live". "I
saw the man on the hill" is a SEE predicate that refers, with a
NodeProxy object, to a "man on the hill" noun. If we edit the "man
on the hill" to say "man beside the barn", the "see" predicate will
still work because the same NodeProxy object has simply been given
a new definition. It will automatically start reading: "I saw the
man beside the barn." Unfortunately, if we undo both predicates --
destroying the GenericNode tied to the NodeProxy argument -- and
then try to redo, the "see" will throw an exception when the
NodeProxy object sees its GenericNode is gone forever. The only
way around this is to intern both predicate commands, so that even
though the "see" predicate uses a NodeProxy in the live data
structure, in the memento it literally says (with a NodeAddress) "I
saw the man ON THE HILL." This is interning: converting a
reference to a value for a re-entrant memento.
On the other hand, when we DO redo, we want to dereference the
object back from the value back to the reference before placing it
back in the live data structure. We don't want the static version
put back directly from the memento. We want to un-intern the
object upon redo (in the case of the above example, finding the new
GenericNode and NodeProxy that has been assigned to "man on the
hill". This is the function of unintern() -- to return an
uninterned version of the same object.
intern
java.lang.Object intern()
throws Scheherexception
- Throws:
Scheherexception
unintern
java.lang.Object unintern()
throws Scheherexception
- Throws:
Scheherexception
isInterned
boolean isInterned()
Copyright © 2011 David K. Elson. All Rights Reserved.