|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-08-01 16:09:39
Hugo Duncan wrote:
>>> Ideally, though, I was looking for a solution that allowed me to reuse
>>> the delay buffer without modifying it. That way it could be used as a
>>> lower layer for any algorithm that needed recent time history. Maybe I
>>> am
>>> being over ambitious...
>> The coupling of the cache_size and the coefficients parameters has to be
>> expressed in code somewhere. Where do you suggest?
>
> It would be nice to do it in the filter code. The coefficents parameter
> is a parameter of the filter after all, and the use of the delay can be
> looked at as an implementation detail. If the filter constructor (body)
> could access the delay buffer, then the delay buffer could expose a method
> to allow resizing. Is that possible?
Ah, ok. Yes, that's possible. In the version you have, that would be
done with a post-constructor. In the post-review version (which I
haven't made available yet), post-constructors are dead, accumulators
within the set are guaranteed to be constructed only after the
accumulators on which they depend are constructed, and the entire
accumulator_set is available in the argument pack.
You'd basically do something like:
template<class Args>
filter_impl(Args const &args)
: ...
{
// filter depends on delay_buffer, so delay_buffer is
// guaranteed to be constructed already.
find_accumulator<tag::delay_buffer>(args[accumulator]).
resize(boost::size(args[coefficients]));
}
I'll try to package up the latest version of accumulators Real Soon. If
you can't wait, just put the same code in a member function called
post_construct and it should do the right thing. Either way, you'll need
to write your delay_buffer_impl so that it works when cache_size is not
specified.
-- Eric Niebler Boost Consulting www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk