Boost logo

Boost :

Subject: [boost] [accumulators] serialization support
From: Zoran Angelov (baldzar_at_[hidden])
Date: 2010-11-19 05:06:48


Hi,
Have anyone considered for boost.accumulators having a serialization
support?
It will be helpful for example in situations where data is being
accumulated/sampled on long time intervals, and persistence of
boost.accumulators objects is impossible.
Something like this:

boost/accumulators/statistics/count.hpp:
.
.
.
template<typename Sample, typename Tag>
    struct immediate_mean_impl
      : accumulator_base
    {
        // for boost::result_of
        typedef typename numeric::functional::average<Sample,
std::size_t>::result_type result_type;

        template<typename Args>
        immediate_mean_impl(Args const &args)
          : mean(numeric::average(args[sample | Sample()],
numeric::one<std::size_t>::value))
        {
        }

        template<typename Args>
        void operator ()(Args const &args)
        {
            std::size_t cnt = count(args);
            this->mean = numeric::average(
                (this->mean * (cnt - 1)) +
args[parameter::keyword<Tag>::get()]
              , cnt
            );
        }

        result_type result(dont_care) const
        {
            return this->mean;
        }

template <typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(mean);
}

    private:
        result_type mean;
    };
.
.
.

The problem is that members, storing the state are private.

Thanks


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk