Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ Message map/decoding pattern?

Reply
Thread Tools

C++ Message map/decoding pattern?

 
 
Scott Fraysia
Guest
Posts: n/a
 
      06-03-2004
The product I am working on will employ a messaging scheme to
communicate between components. This therefore requires that a message
'mapping' mechanism be implemented to identify and decode messages and
delegate the processing of each message to the appropriate handler.

I have seen how, for instance, MFC uses a set of macros to construct a
'message map', but I would prefer that macros were not used. On first
glance I was thinking along the lines of a member-function
template/functor.

In effect, I'm looking for an extensible OO/Pattern based way of
constructing a mapping of various message 'triggers' to handlers, such
as:

if (message is of type 'a')
call handler for messages of type 'a'
else if (message is from component 'b')
call handler for messages from component 'b'
else if (message contains data of type 'c'
call handler for messages containing data of type 'c'

etc

I was hoping not to have to call each and every handler, as there is
likely to be 100s of components, so calling all handlers for all
components when a message is 'broadcast' would likely become rather
inefficient.

Any ideas on books/pattern references ?

I havent seen any of the GOF patterns matching this really, but then,
I could be mistaken.

Scott.
 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      06-03-2004
Scott Fraysia wrote:

> The product I am working on will employ a messaging scheme to
> communicate between components. This therefore requires that a message
> 'mapping' mechanism be implemented to identify and decode messages and
> delegate the processing of each message to the appropriate handler.
>
> I have seen how, for instance, MFC uses a set of macros to construct a
> 'message map', but I would prefer that macros were not used. On first
> glance I was thinking along the lines of a member-function
> template/functor.
>
> In effect, I'm looking for an extensible OO/Pattern based way of
> constructing a mapping of various message 'triggers' to handlers, such
> as:
>
> if (message is of type 'a')
> call handler for messages of type 'a'
> else if (message is from component 'b')
> call handler for messages from component 'b'
> else if (message contains data of type 'c'
> call handler for messages containing data of type 'c'


Read the Prototype and two Factory Patterns from the book /Design Patterns/.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
Reply With Quote
 
 
 
 
Dave Townsend
Guest
Posts: n/a
 
      06-03-2004
Have you considered chain-of-responsibility pattern ?

"Scott Fraysia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> The product I am working on will employ a messaging scheme to
> communicate between components. This therefore requires that a message
> 'mapping' mechanism be implemented to identify and decode messages and
> delegate the processing of each message to the appropriate handler.
>
> I have seen how, for instance, MFC uses a set of macros to construct a
> 'message map', but I would prefer that macros were not used. On first
> glance I was thinking along the lines of a member-function
> template/functor.
>
> In effect, I'm looking for an extensible OO/Pattern based way of
> constructing a mapping of various message 'triggers' to handlers, such
> as:
>
> if (message is of type 'a')
> call handler for messages of type 'a'
> else if (message is from component 'b')
> call handler for messages from component 'b'
> else if (message contains data of type 'c'
> call handler for messages containing data of type 'c'
>
> etc
>
> I was hoping not to have to call each and every handler, as there is
> likely to be 100s of components, so calling all handlers for all
> components when a message is 'broadcast' would likely become rather
> inefficient.
>
> Any ideas on books/pattern references ?
>
> I havent seen any of the GOF patterns matching this really, but then,
> I could be mistaken.
>
> Scott.



 
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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thunderbird - message exceeds the Maximum Message Size? Gerry Firefox 0 02-18-2005 06:39 PM
Error message different than Context.Server.GetLastError.Message tshad ASP .Net 0 01-27-2005 06:38 PM
New OWA message and Modify body of Message - Steve - ASP .Net 0 07-06-2004 04:54 AM
Size of e-mail message - message.Body = msgText =?Utf-8?B?bWc=?= ASP .Net 1 02-11-2004 07:42 PM
Combining message.BodyFormat = MailFormat.Html & message.BodyFormat = MailFormat.Text =?Utf-8?B?bWc=?= ASP .Net 1 02-08-2004 10:43 PM



Advertisments