Authors
- David Chisnall
-
- Declared in:
- ETDeserializer.h
Deserializer. Performs construction of object
graphs based on instructions received from back end.
Each back end is expected to read data representing
serialized objects and pass it to an instance of
this class to perform the deserialization.
Instance Variables
Method summary
+ (void)
registerDeserializer: (
custom_deserializer)aDeserializer
forStructNamed: (char*)aName;
Register a custom deserializer for a specific type
of structure. If a custom deserializer is registered for
a specific type of structure then this will have
responsibility for loading fields in the
specified structure delegated to it.
- (void)
beginArrayNamed: (char*)aName
withLength: (unsigned int)aLength;
Begin an array, with the specified length. All
subsequent load commands from the deserializer
until the corresponding
-endArray
call will be treated as elements of this array.
- (void)
beginObjectWithID: (
CORef)aReference
withClass: (Class)aClass;
Begin deserializing an object which is an instance of
aClass and uniquely identified with
aReference within the set of objects for
which the current backend instance is responsible.
- (void)
beginStruct: (char*)aStructName
withName: (char*)aName;
Begin deserializing a structure. All calls to the
deserializer between this and the
corresponding
-endStruct
call will be assumed to be fields within the
structure.
- (void)
endArray;
End the current array and return to the previous
deserialization mode.
- (void)
endObject;
Indicate that the object currently being loaded is
now finished.
- (void)
endStruct;
End deserializing a C structure.
- (void)
loadCString: (char*)aCString
withName: (char*)aName;
Set the instance variable aName to the value
of aCString, copying the data.
- (void)
loadChar: (char)aChar
withName: (char*)aName;
Set the instance variable aName to the value
of aChar.
- (void)
loadClass: (Class)aClass
withName: (char*)aName;
Set the instance variable aName to the value
of aClass.
- (void)
loadData: (void*)aBlob
ofSize: (size_t)aSize
withName: (char*)aName;
Set the instance variable aName to the value
of aBlob, copying the data.
- (void)
loadDouble: (double)aDouble
withName: (char*)aName;
Set the instance variable aName to the value
of aDouble.
- (void)
loadFloat: (float)aFloat
withName: (char*)aName;
Set the instance variable aName to the value
of aFloat.
- (void)
loadInt: (int)aInt
withName: (char*)aName;
Set the instance variable aName to the value
of aInt.
- (void)
loadLong: (long)aLong
withName: (char*)aName;
Set the instance variable aName to the value
of aLong.
- (void)
loadLongLong: (long long)aLongLong
withName: (char*)aName;
Set the instance variable aName to the value
of aLongLong.
- (void)
loadObjectReference: (
CORef)aReference
withName: (char*)aName;
Set the instance variable aName, which is a
object reference, to the object referenced by
aReference. This may be deferred until the
object is loaded.
- (void)
loadSelector: (SEL)aSelector
withName: (char*)aName;
Set the instance variable aName to the value
of aSelector.
- (void)
loadShort: (short)aShort
withName: (char*)aName;
Set the instance variable aName to the value
of aShort.
- (void)
loadUUID: (unsigned char*)aUUID
withName: (char*)aName;
- (void)
loadUnsignedChar: (unsigned char)aChar
withName: (char*)aName;
Set the instance variable aName to the value
of aChar.
- (void)
loadUnsignedInt: (unsigned int)aInt
withName: (char*)aName;
Set the instance variable aName to the value
of aInt.
- (void)
loadUnsignedLong: (unsigned long)aLong
withName: (char*)aName;
Set the instance variable aName to the value
of aLong.
- (void)
loadUnsignedLongLong: (unsigned long long)aLongLong
withName: (char*)aName;
Set the instance variable aName to the value
of aLongLong.
- (void)
loadUnsignedShort: (unsigned short)aShort
withName: (char*)aName;
Set the instance variable aName to the value
of aShort.
- (id)
lookUpObjectForUUID: (unsigned char*)aUUID;
Look up the object with aUUID. By default,
returns a retained UUID instance. If you don't use
CoreObject, you may patch this method with a
category to implement a custom strategy that
resolve objects associated with UUIDs.
- (id)
restoreObjectGraph;
Restore the principle object from the back end, and
any objects referenced by this object, recursively.
- (void)
setBackend: (id<
ETDeserializerBackend>)aBackend;
Sets the back end which sends events to this
deserializer.
- (BOOL)
setBranch: (
NSString*)aBranch;
Set the branch from which to deserialize.
- (void)
setClassVersion: (int)aVersion;
Set the version of the class responsible for the next
set of instance variables to be loaded. This will be
called multiple times for an object which is of a
class which inherits from another class with instance
variables. This value will be passed to the
object's manual deserialization method, and can be
used to implement deserialization of older versions
(or even newer ones).
- (void)
setReferenceCountForObject: (
CORef)anObjectID
to: (int)aRefCount;
Set the reference count of the object referenced by
anObjectID to aRefCount.
- (int)
setVersion: (int)aVersion;
Set the version to deserialize next.
Instance Variables for ETDeserializer Class
@protected id backend;
The backend sending messages to this deserializer.
@protected int classVersion;
The version of the class being loaded. Used by custom
deserializers to provide backwards
compatibility.
@protected NSMutableArray* invocations;
List of ETInvocationDeserializers used to deserialize
invocations in the object graph. These should
not be destroyed until after the invocations have been
fired.
@protected BOOL isInvocation;
Flag indicating whether the current object is an
invocation. Used to to special case (read: ugly
hack) deserialization for invocations.
@protected int loadedIVar;
Index of last loaded instance variable. Used to
accelerate lookup of the next one.
@protected NSMutableArray* loadedObjectList;
List of loaded object. Iterated over to perform
post-deserialization tidy-up of loaded
objects.
@protected NSMapTable* loadedObjects;
A mapping between CORef references and loaded objects,
used to set object pointers to the correct value.
@protected id object;
Object currently being deserialized
@protected NSMapTable* objectPointers;
A mapping between pointers and the CORef references of
the objects to which they should point. Used to allow
allow object a to be loaded before object b if a
contains a pointer to b as an ivar.
@protected int stackTop;
Offset within the state machine stack of the top
@protected ETDeserializerState states;
State machine stack.
- Declared in:
- ETDeserializer.h
Processes that want to vend out ETDeserializer
instances via Distributed Objects shall implement
the ETDeserializerVendor protocol.
Method summary
- (
ETDeserializer*)
deserializerWithBackend: (
NSString*)backendClassString
forObjectWithUUID: (ETUUID*)uuid
from: (
NSString*)sender;
Creates a deserializer for the named backend. The
vending application may use the uuid and
sender variables to determine additional
details. If the application requesting the object
is using an XMPPObjectStore, sender will
refer to the JID of the user that is trying to sent
an object graph.
- (void)
obtainedObject: (id)object
withUUID: (ETUUID*)uuid
from: (
NSString*)senderJID;
This method can be called by the requesting
application to inform the vending process about
successful deserialization.
typedef void*(* custom_deserializer;
Custom deserializer for a specific structure.
void * custom_deserializer(char* varName,
void * aBlob,
void * aLocation);
The varName
argument contains the name of
the variable to be deserialized, as set by the
corresponding custom serializer function.
The aBlob
argument points