home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Source / MiscLinkedListNode.m < prev    next >
Encoding:
Text File  |  1994-01-30  |  2.8 KB  |  133 lines

  1. //
  2. //    MiscLinkedListNode.m -- internal class used by MiscLinkedList
  3. //        Written by Sean Luke (c) 1993, 1994 by Sean Luke.
  4. //        Additional methods and editing by Don Yacktman.
  5. //                Version 0.9.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. #import <misckit/misckit.h>
  16.  
  17. @implementation MiscLinkedListNode
  18.  
  19. - initObject:this_object
  20.     {
  21.     id returnval=[super init];
  22.     the_object=this_object;
  23.     return returnval;
  24.     }
  25.  
  26.  
  27. - freeObject
  28.     {
  29.     [the_object free];
  30.     the_object = nil;
  31.     return self;
  32.     }
  33.     
  34.     
  35. - getObject
  36.     {
  37.     return the_object;
  38.     }
  39.  
  40.  
  41.  
  42. - setObject: this_object;
  43.     {
  44.     id old_object = the_object;
  45.     the_object=this_object; 
  46.     return old_object;    
  47.     }
  48.  
  49.  
  50.  
  51. - getNext;
  52.     {
  53.     return the_next_node;
  54.     }
  55.  
  56.  
  57.  
  58. - setNext: this_node;
  59.     {
  60.     the_next_node=this_node;
  61.     return the_next_node;    
  62.     }
  63.  
  64.  
  65.  
  66. - getPrevious;
  67.     {
  68.     return the_previous_node;
  69.     }
  70.  
  71.  
  72.  
  73. - setPrevious: this_node;
  74.     {
  75.     the_previous_node=this_node;
  76.     return the_previous_node;    
  77.     }
  78.     
  79. - read: (NXTypedStream*) stream
  80.     {
  81.     [super read:stream];
  82.     the_object=NXReadObject(stream);
  83.             // reads in object and sets it to the_object;
  84. // The linked list object will handle setting these up if the whole list
  85. // was archived, so we won't do it here:
  86. //    the_next_node=NXReadObject(stream); // nil unless whole list was archived
  87. //    the_previous_node=NXReadObject(stream);
  88.     return self;
  89.     }
  90.     
  91. - write: (NXTypedStream*) stream    
  92.     {
  93.     [super write:stream];
  94.     NXWriteObject(stream, the_object); // writes out the_object.
  95.             // it makes no sense for write to write out the_next_node
  96.             // or the_previous_node, since these pointers will change,
  97.             // unless the _whole_ list is being archived.
  98. // The linked list object will handle setting these up if the whole list
  99. // was archived, so we won't do it here:
  100. //    NXWriteObjectReference(stream, the_next_node);
  101. //    NXWriteObjectReference(stream, the_previous_node);
  102.     return self;
  103.     }
  104.  
  105. // NXTransport protocol implementation:
  106. - encodeUsing:(id <NXEncoding>)portal
  107. { // we don't encode pointers; they're handled by the list itself.
  108.     [portal encodeObjectBycopy:the_object];
  109.             // we may want to allow user to control this...
  110.     return self;
  111. }
  112.  
  113. - decodeUsing:(id <NXDecoding>)portal
  114. {
  115.     the_object = [portal decodeObject];
  116.     return self;
  117. }
  118.  
  119. - encodeRemotelyFor:(NXConnection *)connection
  120.     freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isByCopy
  121. {
  122.     if (isByCopy) {
  123.         *flagp = NO; // object will copy.
  124.         return self; //encode object (copy it)
  125.     }
  126.     *flagp = NO; // object will copy.
  127.     // super will encode the proxy otherwise
  128.     return [super encodeRemotelyFor:connection
  129.                 freeAfterEncoding:flagp isBycopy:isByCopy];
  130. }
  131.  
  132. @end
  133.