home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscLinkedListNode.m -- internal class used by MiscLinkedList
- // Written by Sean Luke (c) 1993, 1994 by Sean Luke.
- // Additional methods and editing by Don Yacktman.
- // Version 0.9. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import <misckit/misckit.h>
-
- @implementation MiscLinkedListNode
-
- - initObject:this_object
- {
- id returnval=[super init];
- the_object=this_object;
- return returnval;
- }
-
-
- - freeObject
- {
- [the_object free];
- the_object = nil;
- return self;
- }
-
-
- - getObject
- {
- return the_object;
- }
-
-
-
- - setObject: this_object;
- {
- id old_object = the_object;
- the_object=this_object;
- return old_object;
- }
-
-
-
- - getNext;
- {
- return the_next_node;
- }
-
-
-
- - setNext: this_node;
- {
- the_next_node=this_node;
- return the_next_node;
- }
-
-
-
- - getPrevious;
- {
- return the_previous_node;
- }
-
-
-
- - setPrevious: this_node;
- {
- the_previous_node=this_node;
- return the_previous_node;
- }
-
- - read: (NXTypedStream*) stream
- {
- [super read:stream];
- the_object=NXReadObject(stream);
- // reads in object and sets it to the_object;
- // The linked list object will handle setting these up if the whole list
- // was archived, so we won't do it here:
- // the_next_node=NXReadObject(stream); // nil unless whole list was archived
- // the_previous_node=NXReadObject(stream);
- return self;
- }
-
- - write: (NXTypedStream*) stream
- {
- [super write:stream];
- NXWriteObject(stream, the_object); // writes out the_object.
- // it makes no sense for write to write out the_next_node
- // or the_previous_node, since these pointers will change,
- // unless the _whole_ list is being archived.
- // The linked list object will handle setting these up if the whole list
- // was archived, so we won't do it here:
- // NXWriteObjectReference(stream, the_next_node);
- // NXWriteObjectReference(stream, the_previous_node);
- return self;
- }
-
- // NXTransport protocol implementation:
- - encodeUsing:(id <NXEncoding>)portal
- { // we don't encode pointers; they're handled by the list itself.
- [portal encodeObjectBycopy:the_object];
- // we may want to allow user to control this...
- return self;
- }
-
- - decodeUsing:(id <NXDecoding>)portal
- {
- the_object = [portal decodeObject];
- return self;
- }
-
- - encodeRemotelyFor:(NXConnection *)connection
- freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isByCopy
- {
- if (isByCopy) {
- *flagp = NO; // object will copy.
- return self; //encode object (copy it)
- }
- *flagp = NO; // object will copy.
- // super will encode the proxy otherwise
- return [super encodeRemotelyFor:connection
- freeAfterEncoding:flagp isBycopy:isByCopy];
- }
-
- @end
-