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

  1. Xref: sparky comp.lang.c++:20072 comp.std.c++:2142
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!rational.com!thor!rmartin
  4. From: rmartin@thor.Rational.COM (Bob Martin)
  5. Subject: Re: Callbacks -- suggested approaches??
  6. Message-ID: <rmartin.728265432@thor>
  7. Sender: news@rational.com
  8. Organization: Rational
  9. References: <DAVIDM.93Jan25171343@consilium.com> <rmartin.728090477@stripe> <DAVIDM.93Jan28105805@consilium.com>
  10. Date: Thu, 28 Jan 1993 23:57:12 GMT
  11. Lines: 37
  12.  
  13. davidm@consilium.com (David S. Masterson) writes:
  14.  
  15. |The problem in what you describe is still one of dispatching the message
  16. |received by a process to the appropriate object that will handle the message.
  17. |The issue is what does the dictionary look like and how does the process read
  18. |it and know what to call.  Here you must assume that the number of messages
  19. |that the dictionary can interpret is sufficiently large and diverse (ie. not
  20. |all the same type) in order to make the solution interesting.  For the most
  21. |part, the question is one of syntax allowed by C++ (ie. what's the most
  22. |type-safe way of doing it?) rather than one of modelling (there are many
  23. |models that may be chosen).
  24.  
  25. All messages derive from an abstract class Packet.  Although the
  26. structure of each packet is different, they all have one thing in
  27. common, they know the ID of the object that they are being sent to.
  28. The process receiving the packet asks the packet who it is for and
  29. then looks that ID up in a Dictionary.  The Dictionary associates the
  30. ID with a Receiver object.  Receiver is an abstract base class which
  31. knows how to receive a Packet.  Subclasses of Receiver know how to
  32. decipher a packet and build a message for the target object.  They
  33. also contain a pointer to the target object so that they can send the
  34. message.
  35.  
  36. The only type-system problem in this scheme is in the Receiver which
  37. must accept a generic Packet and then decide what "Type" of packet it
  38. is.  It may than be forced to downcast the packet to the correct type.
  39.  
  40. Even this downcast may be eliminated if a reasonable presentation
  41. layer scheme is used to codify the packet.  Something like X.209 (the
  42. companion to ASN.1)  
  43.  
  44.  
  45. --
  46. Robert Martin       | Design Consulting    | Training courses offered:
  47. R. C. M. Consulting | rmartin@rational.com |  Object Oriented Analysis
  48. 2080 Cranbrook Rd.  | Tel: (708) 918-1004  |  Object Oriented Design
  49. Green Oaks, Il 60048| Fax: (708) 918-1023  |  C++
  50.