Re: I/O streaming with custom data transport



Dmitry A. Kazakov wrote:

In C++ the IOStreams library allows to vary the behaviour of the stream by decoupling formatting from data buffering and transport to the physical device, which are in turn strategies for the stream object. This means that having millions of functions like this:

void foo(ostream &s)
{
s << "Hello";
s << someObject;
s << someOtherObject;
// ...
}

(and *there are* millions of functions like this)

Alas, because it is a poor design based on ad-hoc polymorphism. All these
millions are overloaded.

I don't understand. The focus here is on foo - which represents the set of functions that can use the stream without really caring what the stream is.

In Ada it is exactly same. Consider:

Put (S : in out My_Root_Stream; X : String);
Put (S : in out My_Root_Stream; X : SomeObject);
...

An alternative design (still non-MD) is:

Put (S : in out Root_Stream'Class; X : String);
Put (S : in out Root_Stream'Class; X : SomeObject);
...

This achieves what you want. You can implement I/O on an object type like
String using some common class-wide functionality of streams and then
re-use it over all possible streams.

OK, now I see - there is a bit of misunderstanding. I'm not asking about how to provide new formatting, but rather how to provide new data transport. The practical intention is that I want to write some code that will be reused both with file streams and with network streams (for example).

Please see the example code in my reply to Alex, I think I've found the functionality that I'm looking for.

--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
.



Relevant Pages

  • strxnet 0.9.2.8 Released - XTI Library for Linux Fast-STREAMS
    ... of the X/Open Transport Interface or SVID Transport Layer Interface ... The STREAMS module timod is pushed on any Stream ... Corrections for and testing of 64-bit clean compile and test runs on ...
    (comp.os.linux.announce)
  • Re: Recording to Multiple MPEG2 files
    ... There are three ways of writing out an MPEG file, elementary streams, ... Transport and Program streams contains Elementary streams. ...
    (microsoft.public.win32.programmer.directx.video)
  • streams ora-23621 - transport tablespace
    ... I tried to transport a tablespace from one db to another using Streams ... Prev by Date: ...
    (comp.databases.oracle.server)
  • Re: I/O streaming with custom data transport
    ... which are in turn strategies for the stream object. ... You can implement I/O on an object type like ... String using some common class-wide functionality of streams and then ... and this type is just a name placeholder in ARM). ...
    (comp.lang.ada)