By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

design problem - message translator

P: n/a

Facing a design problem here and I'm not sure how to solve this. The
system consists of bi-directional communication between a subject
communicating with two (at least for now ) listeners. Message
translation needs to occur during communication. Each message
between subject and listener contains 30 words where each word is
16bits in size. The first word in each message is a header.

Communication between Subject and Listeners can be described as
follows: Subject sends an ST1 message to Listeners.

Listeners 1 will extract the words from an ST1 message that is
important to Listener 1 and in doing so build an LR1 and LR2
message. LR1 and LR2 are messages Listener 1 understands. In other
words, Words 4,5,8 and 10 from an ST1 message gets copied into an LR1
message. Words 2,5,9,15,17 and 21 from an ST1 message gets copied
into an LR2 message.

Listeners 2 will extract the words from an ST1 message that is
important to Listener 2 and in doing so build an LR3 and LR4
message. LR3 and LR4 are messages Listener 2 understands. In other
words, Words 2,4,22,24,26 and 28 from an ST1 message gets copied into
an LR3 message. Words 12,17,19,20,22, and 27 from an ST1 message
gets copied into an LR4 message.

In my current design each Listener gets an ST1 message and this is
quickly becoming a maintenance nightmare. I'd like to place a message
handler/translator in the middle. The message translators job is to
translate an ST1 message into the appropriate format the Listener
understands. The translator will then give the Listener an LR1,LR2
(Listener1) or LR3,LR4(Listener2) message. I believe that a generic
solution exists that will accomplish the goal of the translator but
I'm not sure how to do this. I'm not sure how to structure the
translator and in doing so exploit C++ template facilities to
accomplish my objective.
Any help appreciated. Thanks in advance.
Oct 12 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sam
fo*******@hotmail.com writes:
[ long winded description ]

understands. The translator will then give the Listener an LR1,LR2
(Listener1) or LR3,LR4(Listener2) message. I believe that a generic
solution exists that will accomplish the goal of the translator but
I'm not sure how to do this. I'm not sure how to structure the
translator and in doing so exploit C++ template facilities to
accomplish my objective.
I see no reason for an overcomplicated solution. As I understand it, you
only need a generic superclass that retrieves an arbitrary elements from an
array, whose indexes are specified by a subclass. Then, you define the
appropriate subclasses for each one of your LRn messages.

Problem solved.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkjxbpsACgkQx9p3GYHlUOIragCfSu4hG0qSFP wUWgb+hqHQgZ2n
sNkAn2Lm0/zWHfxzCWM4Sxi2Mi4N67tO
=uLyd
-----END PGP SIGNATURE-----

Oct 12 '08 #2

P: n/a
On Oct 12, 4:58*am, forums...@hotmail.com wrote:
Facing a design problem here and I'm not sure how to solve
this. * The system consists of bi-directional communication
between a subject communicating with two (at least for now )
listeners. * *Message translation needs to occur during
communication. * Each message between subject and listener
contains 30 words where each word is 16bits in size. *The
first word in each message is a header.
Communication between Subject and Listeners can be described
as follows: *Subject sends an ST1 message to Listeners.
Listeners 1 will extract the words from an ST1 message that is
important to Listener 1 and in doing so build an LR1 and LR2
message. * LR1 and LR2 are messages Listener 1 understands. *
In other words, *Words 4,5,8 and 10 from an ST1 message gets
copied into an LR1 message. * Words 2,5,9,15,17 and 21 from an
ST1 message gets copied into an LR2 message.
Listeners 2 will extract the words from an ST1 message that is
important to Listener 2 and in doing so build an LR3 and LR4
message. * LR3 and LR4 are messages Listener 2 understands. *
In other words, *Words 2,4,22,24,26 and 28 from an ST1 message
gets copied into an LR3 message. * Words 12,17,19,20,22, and
27 from an ST1 message gets copied into an LR4 message.
In my current design each Listener gets an ST1 message and
this is quickly becoming a maintenance nightmare. *I'd like to
place a message handler/translator in the middle. *The message
translators job is to translate an ST1 message into the
appropriate format the Listener understands. *The translator
will then give the Listener an LR1,LR2 (Listener1) or
LR3,LR4(Listener2) message. * *I believe that a generic
solution exists that will accomplish the goal of the
translator but I'm not sure how to do this. * I'm not sure how
to structure the translator and in doing so exploit C++
template facilities to accomplish my objective.
This sounds more or less like you want the adapter pattern,
although I'm not too sure why only accessing a subset of the
information in a given message is becoming a maintenance
nightmare.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 12 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.