How to access one specific lowlevel object through a general highlevel interface?



Hello all,

I have a problem for which my solution feels like a hack. :-(
I'd like to change that :-)

The real problem can be destilled to something like this:
One client wants to send data using one specific top layer
protocol. At this top layer, there are a number of different
protocols, where each one inherits the main Protocol class.
And every protocol subclass in turn contains several different
communication channels that inherits the Channel class.
So, a client knows about several different high level protocols
and each protocol has many channels.

Now, when data is to be sent, we must send that data over the
"most appropriate" communication channel. This channel can be
found by traversing the hierarchy of protocols and channels.

However, after we have found the "best" channel, we cannot send
data through this channel directly! Instead we must send data
through the specific protocol which the selected channel belongs to.

Therefore, one can let each channel be aware of its parent protocol,
and this allows for a solution to expressed in code like:

Channel* channel = GetBestChannel();
Protocol* protocol = channel->GetProtocol();
protocol->SendData(channel,"Hello world!");

where

ProtocolX::SendData(const Channel* channel, const char* data)
{
// First...
DoSomeProtocolXSpecificStuff();
// Then send the data through the selected channel
channel->SendData(data);
}

The things that I do not like about this solution is that I do not
want the Channel class to be unveiled. The client shouldn't
care about the channels, it shouldn't be aware of their existance.
In addition to this, I do not like that each channel must be aware
of its parent protocol.

So, is there another solution for this recurring(?) problem, a pattern
maybe, or do I have to accept my current solution?

/Rob



.



Relevant Pages

  • Re: How to access one specific lowlevel object through a general highlevel interface?
    ... But your body description of the problem sounds like a network access problem where the concerns are protocol conversion and hardware allocation. ... communication channels that inherits the Channel class. ... The R1 relationship defines the hierarchy of protocols. ... selection criteria to each Protocol encountered. ...
    (comp.object)
  • Re: SoapClient reply transport issue
    ... If not on the same channel then you can change protocol using ReplyTo and it ... will be regarded as a different endpoint so you have to register an endpoint ... > SoapClient erroneously retrieves the ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: ZoneAlarm blocks FTP apps
    ... > packet from any computer using whatever protocol. ... > channel) using different ports and that there are two possibilities ... > are handled and set up between client and server. ...
    (comp.security.firewalls)
  • Re: Wierd TCP socket problem
    ... we see that the client part of channel to server is ... The server still thinks that client is up. ... If the protocol you are using doesn't, ...
    (comp.os.linux.networking)
  • Re: How to access one specific lowlevel object through a general highlevel interface?
    ... If your client needn't know about channel because, for example, the ... the only way out is to define a bootstrap protocol (always the ... strategy for selecting channels. ...
    (comp.object)