|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--org.abora.gold.java.AboraHeaper
|
+--org.abora.gold.xpp.basic.Heaper
|
+--org.abora.gold.xpp.converters.Converter
Converters exist to convert an object that is of one data type to some other data type.
In order to understand why we use Converters for this, we first have to understand why the
two obvious C++ means for doing so are inadequate.
First, we could send a conversion message to the object that we''re converting from. This
has the disadvantage that the module which provides the object must know all the types
that we might want to convert it to. This effectively prevents the easy addition of new
types to an existing system (without coordinating overhead).
Second, we could use pseudo-constructors for the new type which were overloaded based of
the type of the argument (to be converted from). The problem is that overloading only
happens based on compile time type, and we want to invoke the converter that is most
specific based on the run-time type. Let''s say that "p" is declared as pointer to
Position, but at the moment it points to an Integer. If a converter has been provided by
someone for converting Integers to the target type we would prefer that one. The CHOOSE
macro doesn''t help, because that only converts run time types to particular compile time
types which the user of the CHOOSE macro thought to list.
Instead, one declares a static instance of each Converter which (at initialization time)
posts itself to a table of all converters, indexed by the from-class and the to-class. At
run-time, when we use the CONVERT macro to convert an object to a desired type, the most
specific converter based on the from-type hierarchy is selected. I believe that currently
any compatable to-type is acceptable (with no preference). The selected converter''s from
type may be a superclass of the from-object, and the converter''s to-type may be any
subclass of the requested to type.
Example:
"CONVERT(XuRegion,p)" when p is bound to a position will return a singleton region of the
same coordinate space as that of the position. In Smalltalk, one says "p convert:
XuRegion".
See Scaffold and WaldoMaker for services which are similar to that provided by Converter.
Eventually we hope to unify some of these.
| Field Summary | |
protected static CategoryTable |
AllConverters
|
protected static Converter |
LastConverter
|
protected static Category |
LastFrom
|
protected static Category |
LastTo
|
| Fields inherited from class org.abora.gold.xpp.basic.Heaper |
AllBlasts, BecomeMap, GarbageCount, InGC, InitializedClasses, InitializingClasses, LastMemory, NextClientRequestNumber, NotOneElementSignal, PackageTable, PromiseNameTable, StringHashSBoxes |
| Fields inherited from class org.abora.gold.java.AboraHeaper |
ActiveClubs, CurrentAuthor, CurrentBertCanopyCache, CurrentBertCrum, CurrentChunk, CurrentGrandMap, CurrentKeyMaster, CurrentPacker, CurrentSensorCanopyCache, CurrentServer, CurrentSession, CurrentSessions, CurrentTrace, InitialEditClub, InitialOwner, InitialReadClub, InitialSponsor, InsideTransactionFlag |
| Constructor Summary | |
Converter(Category from,
Category to)
remember the kind of converter this is. |
|
| Method Summary | |
int |
actualHashForEqual()
|
static Heaper |
CONVERT(Category to,
Heaper thing)
convert using the best available converter |
Heaper |
convert(Heaper value)
perform the conversion. |
static Converter |
fetchConverter(Category from,
Category to)
find the best available converter. |
static Heaper |
getConversion(Category to,
Heaper value)
get the best converter and use it to actually do the conversion. Clients should only use the CONVERT macro instead |
static Converter |
getConverter(Category from,
Category to)
find the best available converter. |
static void |
initTimeInherited()
create an instance of the converter. |
static void |
initTimeNonInherited()
create an instance and assign it to the class instance variable |
boolean |
isEqual(java.lang.Object other)
|
static void |
linkTimeNonInherited()
create an instance and assign it to the class instance variable |
static void |
suppressInitTimeInherited()
|
static void |
suppressLinkTimeInherited()
|
| Methods inherited from class org.abora.gold.java.AboraHeaper |
asOop, basicInspect, displayString, error, hack, halt, inspect, knownBug, mightNotImplement, REQUIRES, shouldImplement, shouldNotImplement, stubbleForSubclassResponsibility, thingToDo, willNotImplement |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static CategoryTable AllConverters
protected static Converter LastConverter
protected static Category LastFrom
protected static Category LastTo
| Constructor Detail |
public Converter(Category from,
Category to)
| Method Detail |
public Heaper convert(Heaper value)
public int actualHashForEqual()
actualHashForEqual in class Heaperpublic boolean isEqual(java.lang.Object other)
public static Converter fetchConverter(Category from,
Category to)
public static Heaper getConversion(Category to,
Heaper value)
public static Converter getConverter(Category from,
Category to)
public static void initTimeInherited()
public static void initTimeNonInherited()
public static void linkTimeNonInherited()
public static void suppressInitTimeInherited()
public static void suppressLinkTimeInherited()
public static Heaper CONVERT(Category to,
Heaper thing)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||