9 #include <alps/config.hpp> 16 namespace accumulators {
18 class accumulator_wrapper;
22 template<
typename T>
struct serializable_type;
38 insert(it->first, it->second->result());
44 T & operator[](std::string
const & name);
45 T
const & operator[](std::string
const & name)
const;
47 bool has(std::string
const & name)
const;
49 void insert(std::string
const & name, std::shared_ptr<T> ptr);
52 return m_storage.size();
59 template<
typename A>
static void register_serializable_type_nolock();
61 template<
typename A>
static void register_serializable_type();
63 void print(std::ostream & os)
const;
65 iterator
begin() {
return m_storage.begin(); }
66 iterator
end() {
return m_storage.end(); }
68 const_iterator
begin()
const {
return m_storage.begin(); }
69 const_iterator
end()
const {
return m_storage.end(); }
71 void clear() { m_storage.clear(); }
78 template<
typename U = T>
79 typename std::enable_if<std::is_same<U, accumulator_wrapper>::value>::type
81 iterator it1 = this->begin();
82 const_iterator it2 = rhs.
begin();
83 for(; it1 != end(); ++it1, ++it2) {
84 if (it1->first != it2 ->first)
throw std::logic_error(
"Can't merge" + it1->first +
" and " + it2->first);
85 it1->second->merge(*(it2->second));
89 template<
typename U = T>
90 typename std::enable_if<std::is_same<U, accumulator_wrapper>::value>::type
92 for(iterator it = begin(); it != end(); ++it)
97 std::map<std::string, std::shared_ptr<T> > m_storage;
98 static std::vector<std::shared_ptr<detail::serializable_type<T> > > m_types;
99 static std::mutex m_types_mutex;
104 template<
typename T>
inline std::ostream & operator<<(std::ostream & os, const wrapper_set<T> & arg) {
void load(archive &ar, std::string const &path, T &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())
void print(std::ostream &os) const
const_iterator end() const
wrapper_set(wrapper_set< U > const &arg)
std::ostream & print(std::ostream &s, const dict_value &dv, bool terse)
wrapper_set(wrapper_set const &)
const_iterator begin() const
std::map< std::string, std::shared_ptr< T > >::iterator iterator
std::enable_if< std::is_same< U, accumulator_wrapper >::value >::type merge(wrapper_set const &rhs)
Merge another accumulator/result set into this one.
std::map< std::string, std::shared_ptr< T > >::const_iterator const_iterator
std::enable_if< std::is_same< U, accumulator_wrapper >::value >::type reset()
void save(archive &ar, std::string const &path, T const &value, std::vector< std::size_t >=std::vector< std::size_t >(), std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())