home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / remote / transport.h < prev   
Text File  |  1992-05-29  |  3KB  |  67 lines

  1. /* transportW)5* encoding/decoding protocols for DistributedObjects
  2.  * Copyright 1992, NeXT Computer, Inc.
  3.  */
  4.  
  5. #import <objc/Object.h>
  6. #import <mach/port.h>
  7.  
  8. /* these are the general encoding/decoding protocols implemented by all objective-C message buffering/delivery classes */
  9.  
  10. /* The general scheme is that Proxys will encode a method and its arguments onto a portal, and/or decode requests or replies from a portal.  The encoding/decoding protocol allows for potentially different implementations of portals, such as an in memory queue or a TCP channel or a System V STREAMS version... or whatever your favorite connection paradigm is.  Note that the treatment of MACH memory and MACH ports would need to be emulated very closely in any underlying implementation. */
  11.  
  12. @protocol NXEncoding
  13. // encode an objc (parameter) type
  14. - encodeData:(void *)data ofType:(const char *)type;
  15.  
  16. // encoding methods for transcribing custom objects
  17. - encodeBytes:(const void *)bytes count:(int)count;
  18. - encodeVM:(const void *)bytes count:(int)count;
  19. - encodeMachPort:(port_t)port;
  20. - encodeObject:anObject;    // send a ref to the object across
  21. - encodeObjectBycopy:anObject;  // copy the object across
  22.  
  23. @end
  24.  
  25. @protocol NXDecoding
  26. // decode an objc (parameter) type
  27. - decodeData:(void *)d ofType:(const char *)t;
  28.  
  29. // decoding methods for transcribing custom objects
  30. - decodeBytes:(void *)bytes count:(int)count;
  31. - decodeVM:(void **)bytes count:(int *)count;
  32. - decodeMachPort:(port_t *)pp;
  33. - (id) decodeObject;                    // returns decoded object
  34. @end
  35.  
  36. /* Objects that encode themselves "on the wire" need to implement the following methods */
  37.  
  38. @class NXConnection;
  39.  
  40. @protocol NXTransport
  41. // This method is called for every object before encoding.
  42. // It should return self if the object always transcribes itself.
  43. // If the object wants to conditionally transcribe itself depending
  44. // on whether the bycopy keyword is present in the methods protocol
  45. // description, it should return self if isBycopy is true, and
  46. // return [super encodeRemotelyFor...] if false.
  47. // If the object wants another object to be sent, it should return that
  48. // object.
  49. // Setting *flagp to true will cause the returned object to be freed after encoding.
  50. - encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isBycopy;
  51.  
  52. // The object should encode itselfW)6the portal
  53. - encodeUsing:(id <NXEncoding>)portal;
  54. // The object should initialize itself from the portal
  55. - decodeUsing:(id <NXDecoding>)portal;
  56. @end
  57.  
  58.  
  59. /* Object provides an implementation that creates NXProxies on the other side */
  60.  
  61. @interface Object (Object_MakeRemote)
  62. - encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isBycopy;
  63. @end
  64.  
  65.  
  66.  
  67.