|
Boost : |
From: Larry Evans (jcampbell3_at_[hidden])
Date: 2003-06-14 08:59:24
Maxim Egorushkin wrote:
> "Larry Evans" <jcampbell3_at_[hidden]> wrote in message
> news:3EE87CC6.9020905_at_prodigy.net...
[snip]
> I've examined col_io. At a high point of view it is the decorator pattern -
> you extend basic_ostream<> interface with identation capabilities. The code
> I posted, particulary input/output_buffer classes, is the adapter pattern -
> it adds basic_streambuf<> interface to a sequence. So, this patterns have
> different purposes.
Thanks very much. I hadn't realized col_io (or more particularly the
code in test_marg_ostreambuf.zip) was a decorator pattern. However, I
see now that the correspondence with the "Structure" secion on p. 177
of the GOF '95 _Design Patterns_ book. More precisely:
Component -> streambuf
ConcreteComponent -> the streambuf from the original ostream
Decorator -> fwd_ostreambuf
Decorator::Operation -> fwd_ostreambuf::overflow
ConcreteDecoratorA -> marg_ostreambuf
ConcreteDecoratorA::addedState -> marg_put
I'll soon upload a commented an simplified version of marg_ostreambuf
and maybe a templatized version to parameterize the addedState. I may
rename it too to decorated_ostreambuf or something similar.
> If I get you right you want to see how one can add identation capabilites to
> a buffer using the adapters. Well, it could be done but it would be somewhat
> onerous. One would have to wrap an existing buffer with a developed sequence
OK.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk