home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20056 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  3.4 KB

  1. Xref: sparky comp.lang.c++:20056 comp.std.c++:2139
  2. Path: sparky!uunet!cimshop!davidm
  3. From: davidm@consilium.com (David S. Masterson)
  4. Newsgroups: comp.lang.c++,comp.std.c++
  5. Subject: Re: Callbacks -- suggested approaches??
  6. Message-ID: <DAVIDM.93Jan28105805@consilium.com>
  7. Date: 28 Jan 93 18:58:05 GMT
  8. References: <DAVIDM.93Jan25171343@consilium.com> <rmartin.728090477@stripe>
  9. Sender: root@cimshop.UUCP
  10. Organization: Consilium Inc., Mountain View, California
  11. Lines: 50
  12. In-reply-to: rmartin@stripe.Rational.COM's message of 26 Jan 93 23:21:17 GMT
  13. X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]
  14.  
  15. >>>>> On 26 Jan 93 23:21:17 GMT, rmartin@stripe.Rational.COM (Bob Martin) said:
  16.  
  17. > Given that class A wants to send the message X to class B.
  18.  
  19. > Unfortunately, theB lives in another process.  No problem.  Create an
  20. > abstract class called AbstractB.  It contains a set of pure virtual
  21. > functions defining all the messages that B can receive.  B will
  22. > inherit from AbstractB.  So will another class called BSurrogate.
  23. > BSurrogate knows which process the real B object lives in and knows
  24. > how to convert the message into a packet and ship it to that process.
  25. > The packet will contain all the arguments to X, an identifier denoting
  26. > that it represents an X message and the identifier of the B object to
  27. > which the message should be sent.
  28.  
  29. > When the process receives the it looks up the name of the object in a
  30. > dictionary.  The dictionary associates the name with a derivative of
  31. > the class Reciever.  BReceiver is derived from Receiver, and knows how
  32. > to unpack the X packet.  It also knows where the B object is (Probably
  33. > it contains a pointer to it), so it unpacks all the arguments and then
  34. > sends the message to its B object.  
  35.  
  36. > Return values can be passed back by the same route by simply having
  37. > the Surrogate add a return address onto the packet.
  38.  
  39. In a sense, this is what we've done -- our modelling is somewhat different
  40. than your's, though.  The best way I could think of describing the difference
  41. between your model and our model is to look at the IOStream library.  In the
  42. model you describe above, you are basically defining the user interface for
  43. the B::operator<< while we are describing the definition of an Ostream that
  44. will carry the data that operator<< builds to its intended destination.  The
  45. next level (or layer) in our system is really the same as your description.
  46.  
  47. The problem in what you describe is still one of dispatching the message
  48. received by a process to the appropriate object that will handle the message.
  49. The issue is what does the dictionary look like and how does the process read
  50. it and know what to call.  Here you must assume that the number of messages
  51. that the dictionary can interpret is sufficiently large and diverse (ie. not
  52. all the same type) in order to make the solution interesting.  For the most
  53. part, the question is one of syntax allowed by C++ (ie. what's the most
  54. type-safe way of doing it?) rather than one of modelling (there are many
  55. models that may be chosen).
  56. --
  57. ====================================================================
  58. David Masterson                    Consilium, Inc.
  59. (415) 691-6311                    640 Clyde Ct.
  60. davidm@consilium.com                Mtn. View, CA  94043
  61. ====================================================================
  62. "I'll put an end to the idea that a woman's body belongs to her . . . the
  63.  practice of abortion shall be exterminated with a strong hand."
  64. -- Adolf Hitler, _Mein Kampf_
  65.