59class PreloadAdiosAttributes
65 struct AttributeLocation
70 char *destroy =
nullptr;
72 AttributeLocation() =
delete;
73 AttributeLocation(
size_t len,
size_t offset,
Datatype dt);
75 AttributeLocation(AttributeLocation
const &other) =
delete;
76 AttributeLocation &operator=(AttributeLocation
const &other) =
delete;
78 AttributeLocation(AttributeLocation &&other)
noexcept;
79 AttributeLocation &operator=(AttributeLocation &&other)
noexcept;
93 std::vector<char> m_rawBuffer;
94 std::map<std::string, AttributeLocation> m_offsets;
97 explicit PreloadAdiosAttributes() =
default;
98 PreloadAdiosAttributes(PreloadAdiosAttributes
const &other) =
delete;
99 PreloadAdiosAttributes &
100 operator=(PreloadAdiosAttributes
const &other) =
delete;
102 PreloadAdiosAttributes(PreloadAdiosAttributes &&other) =
default;
103 PreloadAdiosAttributes &operator=(PreloadAdiosAttributes &&other) =
default;
122 template <
typename T>
125 Datatype attributeType(std::string
const &name)
const;
127 std::map<std::string, AttributeLocation>
const &availableAttributes()
const;
134 AttributeWithShapeAndResource(
137 std::optional<std::vector<T>> resource_in);
138 AttributeWithShapeAndResource(adios2::Attribute<T> attr);
139 operator bool()
const;
148 std::optional<std::vector<T>> resource;
153 using RandomAccess_t = std::vector<PreloadAdiosAttributes>;
163 size_t m_currentStep = 0;
164 std::optional<std::map<std::string, adios2::Params>> m_attributes;
172 std::variant<RandomAccess_t, StreamAccess_t> m_data =
StreamAccess_t{};
184 template <
typename Functor>
185 auto withAvailableAttributes(
size_t step, adios2::IO &IO, Functor &&f)
186 ->
decltype(std::forward<Functor>(f)(
187 std::declval<std::map<std::string, adios2::Params> &>()))
189 using ret_t =
decltype(std::forward<Functor>(f)(
190 std::declval<std::map<std::string, adios2::Params> &>()));
193 [step, &f](RandomAccess_t &ra) -> ret_t {
194 auto &attribute_data = ra.at(step);
195 return std::forward<Functor>(f)(
196 attribute_data.availableAttributes());
198 [step, &f, &IO](StreamAccess_t &sa) -> ret_t {
199 if (!sa.m_attributes.has_value() ||
200 sa.m_currentStep != step)
202 sa = StreamAccess_t{step, IO.AvailableAttributes()};
204 return std::forward<Functor>(f)(*sa.m_attributes);
209 template <
typename T>
210 AttributeWithShapeAndResource<T>
211 getAttribute(
size_t step, adios2::IO &IO, std::string
const &name)
const;