design problem - message translator

F

forums_mp

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.
 
J

James Kanze

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top