ALPSCore reference
archive_traits.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
9 #pragma once
10 
11 #include <alps/hdf5/archive.hpp>
12 
13 namespace alps {
14  namespace accumulators {
15  namespace detail {
16 
18  template <typename T>
19  struct archive_trait {
20  typedef typename alps::hdf5::scalar_type<T>::type scalar_type;
22 
28  static bool can_load(hdf5::archive& ar,
29  const std::string& name,
30  std::size_t dim) {
31  bool ok=ar.is_data(name) &&
32  !ar.is_attribute(name+"/@c++_type") && // plain types should not have the attribute
33  ar.is_datatype<scalar_type>(name) &&
34  ((dim==0 && ar.is_scalar(name)) ||
35  (dim>0 && ar.dimensions(name)==dim));
36  return ok;
37  }
38  };
39 
40  } // detail::
41  } // accumulators::
42 } // alps::