home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!airgun!airgun.wg.waii.com!bab
- From: bab@se39.wg2.waii.com (Brian Button)
- Newsgroups: comp.lang.c++
- Subject: Re: Discriminating Variant Records Without switch() ??
- Message-ID: <BAB.92Nov12074430@se39.wg2.waii.com>
- Date: 12 Nov 92 12:44:30 GMT
- References: <BAB.92Nov10073324@se39.wg2.waii.com> <1992Nov11.144253.26415@bnr.ca>
- Sender: news@airgun.wg.waii.com
- Organization: Western Geophysical Exploration Products
- Lines: 37
- Nntp-Posting-Host: se39.wg2.waii.com
- In-reply-to: holiday@bnr.ca's message of 11 Nov 92 14:42:53 GMT
-
-
- In article <BAB.92Nov10073324@se39.wg2.waii.com>, bab@se39.wg2.waii.com (Brian Button) writes:
- |> Is there a simple, OOP based way to discriminate between variant
- |> records? I saw an article in C Users Journal last month titled "Switch
- |> Deemed Harmful to C++" or something like that, but I couldn't figure
- |> out how to do it any other way.
-
-
- ->"Matthew" == Matthew Holiday <holiday@bnr.ca> writes:
- Matthew> switch statement! :-) There ought to be a convenient way
- Matthew> to create objects from network messages, i.e., some way to
- Matthew> register message types and their matching class types,
- Matthew> such that for every incoming message, its body (an array
- Matthew> of bytes) gets turned into the correct object, which would
- Matthew> be derived from a root generic message object.
-
- There is such a way using factory classes such as the RogueWave
- RWFactory class. The problem I'm having is figuring out how to deal
- with these objects after they are already created. Since there's no
- common set of operations which are performed on each of the objects,
- there is no set of methods which may be made virtual and overloaded.
- Herein lies the problem. This seems to point towards using special
- purpose code for each class, which would necessitate using a switch.
-
- Have I painted myself into a corner or is there some way out. How are
- the rest of you OOP programmers dealing with cases like this?
-
- bab
-
- --
- |-----------------------|----------------------------------------------------|
- | Brian Button | email : button@wg2.waii.com |
- | Design Engineer | 71023.276@compuserve.com |
- | Western Geophysical | voice : (713)964-6221 |
- | 3600 Briarpark |----------------------------------------------------|
- | Houston, Texas 77042 | Opinions Be Mine!! |
- |-----------------------|----------------------------------------------------|
-