Exforsys

Online Training

Message dispatch problem

This is a discussion on Message dispatch problem within the Software Patterns forums, part of the Testing category; Hello, I need some advice about the following C++ situation: there are two classes, A and B. A knows nothing ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-06-2005, 08:11 PM
Karel Miklav
Guest
 
Posts: n/a
Message dispatch problem

Hello, I need some advice about the following C++ situation: there
are two classes, A and B. A knows nothing about B, but it passes
messages to B, which they both understand. How should I implement
dispatch of these messages in class B? Here are some common but
not good enough solutions:

1. put type enum in messages and implement message as a union
a-la xlib events, dispatch in a loop on type enum
2. make messages polymorphic classes and dispatch on RTTI in a
loop
3. make massages polymorphic classes with common dispatch interface

The third solution looks kind-a nice, but it exposes details of
class B to class A. Is there some well known solution for this
problem?

--

Regards,
Karel Miklav
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-07-2005, 02:23 AM
Nick Malik [Microsoft]
Guest
 
Posts: n/a
Re: Message dispatch problem

http://sern.ucalgary.ca/courses/SENG...serverLib.html

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Karel Miklav" <karel@lovetemple.adbloccker.net> wrote in message
news:dfl7mn01gbv@enews1.newsguy.com...
> Hello, I need some advice about the following C++ situation: there
> are two classes, A and B. A knows nothing about B, but it passes
> messages to B, which they both understand. How should I implement
> dispatch of these messages in class B? Here are some common but
> not good enough solutions:
>
> 1. put type enum in messages and implement message as a union
> a-la xlib events, dispatch in a loop on type enum
> 2. make messages polymorphic classes and dispatch on RTTI in a
> loop
> 3. make massages polymorphic classes with common dispatch interface
>
> The third solution looks kind-a nice, but it exposes details of
> class B to class A. Is there some well known solution for this
> problem?
>
> --
>
> Regards,
> Karel Miklav



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-08-2005, 01:00 AM
Karel Miklav
Guest
 
Posts: n/a
Re: Message dispatch problem

Nick Malik [Microsoft] wrote:
> http://sern.ucalgary.ca/courses/SENG...serverLib.html


Hm, it looks more like command pattern to me. But even then I cannot
completely solve the problem of dispatch - I'd like it to be a matter of
virtual function call or two... Thanks nick for pointing me in the righ
direction, I need some more time now.

--

Regards,
Karel Miklav
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:55 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.