27 #ifndef UTILS_RESULTS_COLLECTOR_H
28 #define UTILS_RESULTS_COLLECTOR_H
31 #include <boost/any.hpp>
32 #include <boost/shared_ptr.hpp>
42 virtual void collect(boost::any
const &) = 0;
43 virtual void save(alps::hdf5::archive & ar)
const = 0;
53 vals.push_back(boost::any_cast<T>(val));
56 void save(alps::hdf5::archive & ar)
const
58 std::vector<T> allvalues;
59 if (ar.is_data(
"mean/value"))
60 ar[
"mean/value"] >> allvalues;
61 std::copy(vals.begin(), vals.end(), std::back_inserter(allvalues));
62 ar[
"mean/value"] << allvalues;
71 typedef boost::shared_ptr<detail::collector_impl_base> coll_type;
74 : collector(collector_)
82 collector->collect(val);
86 coll_type & collector;
103 template <
class Archive>
106 for (std::map<std::string, boost::shared_ptr< ::detail::collector_impl_base> >::const_iterator
107 it = collection.begin(); it != collection.end(); ++it)
109 ar[it->first] << *it->second;
114 std::map<std::string, boost::shared_ptr< ::detail::collector_impl_base> > collection;
virtual void collect(boost::any const &)=0
virtual ~collector_impl_base()
void collect(boost::any const &val)
collector_proxy operator[](std::string name)
void operator<<(T const &val)
collector_proxy(coll_type &collector_)
void save(Archive &ar) const
virtual void save(alps::hdf5::archive &ar) const =0
void save(alps::hdf5::archive &ar) const