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