|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-08-01 14:51:10
Hugo Duncan wrote:
>> The resulting argument pack is passed as the constructor parameter to
>> all the accumulators in the set. Your accumulator can then extract the
>> coefficients argument from the pack with "args[coefficients]".
>
> Done this, but I want to pass an array of values to coefficients, ie it
> looks like, eg:
>
> array<double,5> coeffs={0.1,0.2,0.1};
> accumulator_set<... > acc( .., coefficients = coeffs, ...);
>
> So far so good.
>
> My filter depends on the delay buffer I have defined which has the
> cache_size constructor argument. Since I am specifying the list of
> coefficients, I want the cache_size to be set to the number of elements in
> my coefficient list, with out having to specify it, ie without having to
> write:
>
> array<double,5> coeffs={0.1,0.2,0.1};
> accumulator_set<... > acc( .., coefficients = coeffs, cache_size=5...);
>
> Not sure if this is possible through boost::Parameters (first time I have
> seen this used, BTW, I'm impressed), or if I need to have the filter
> access the delay post construction, or if it is just not possible.
Let me see if I understand. You want the delay buffer to use the
cache_size parameter if it is specified, and if not, check to see if the
coefficients parameter is specified, and if so, use the size of the
coefficients array. This is possible.
In your delay buffer constructor, you can calculate the cache size as:
struct must_specify_cache_size_or_coefficients {};
...
template<class Args>
delay_buffer_impl(Args const &args)
: cache_size_(
args[delay_buffer::cache_size
| boost::size(
args[coefficients
| must_specify_cache_size_or_coefficients()
]
)
]
)
{}
That's not tested -- it's just an idea.
-- 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