Skip to content

Commit

Permalink
Cleanup: No Old* class names
Browse files Browse the repository at this point in the history
Also use new boolean flag in new layout
  • Loading branch information
franzpoeschel committed Aug 18, 2022
1 parent eeb792c commit d089c1d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
13 changes: 7 additions & 6 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ namespace detail
struct DatasetReader;
struct AttributeReader;
struct AttributeWriter;
struct OldAttributeReader;
struct OldAttributeWriter;
struct AttributeReader;
struct AttributeWriter;
template <typename>
struct AttributeTypes;
struct DatasetOpener;
Expand Down Expand Up @@ -113,8 +113,8 @@ class ADIOS2IOHandlerImpl
friend struct detail::DatasetReader;
friend struct detail::AttributeReader;
friend struct detail::AttributeWriter;
friend struct detail::OldAttributeReader;
friend struct detail::OldAttributeWriter;
friend struct detail::AttributeReader;
friend struct detail::AttributeWriter;
template <typename>
friend struct detail::AttributeTypes;
friend struct detail::DatasetOpener;
Expand Down Expand Up @@ -464,10 +464,11 @@ namespace detail
static constexpr char const *errorMsg = "ADIOS2: readDataset()";
};

struct OldAttributeReader
struct AttributeReader
{
template <typename T>
static Datatype call(
ADIOS2IOHandlerImpl &,
adios2::IO &IO,
std::string name,
std::shared_ptr<Attribute::resource> resource);
Expand All @@ -476,7 +477,7 @@ namespace detail
static Datatype call(Params &&...);
};

struct OldAttributeWriter
struct AttributeWriter
{
template <typename T>
static void call(
Expand Down
42 changes: 30 additions & 12 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ void ADIOS2IOHandlerImpl::writeAttribute(
default:
throw std::runtime_error("Unreachable!");
}
switchType<detail::OldAttributeWriter>(
switchType<detail::AttributeWriter>(
parameters.dtype, this, writable, parameters);
}

Expand Down Expand Up @@ -1028,8 +1028,8 @@ void ADIOS2IOHandlerImpl::readAttribute(
name);
}

Datatype ret = switchType<detail::OldAttributeReader>(
type, ba.m_IO, name, parameters.resource);
Datatype ret = switchType<detail::AttributeReader>(
type, *this, ba.m_IO, name, parameters.resource);
*parameters.dtype = ret;
}

Expand Down Expand Up @@ -1516,7 +1516,8 @@ namespace detail
}

template <typename T>
Datatype OldAttributeReader::call(
Datatype AttributeReader::call(
ADIOS2IOHandlerImpl &impl,
adios2::IO &IO,
std::string name,
std::shared_ptr<Attribute::resource> resource)
Expand All @@ -1538,8 +1539,16 @@ namespace detail
name + "'.");
}

std::string metaAttr =
ADIOS2Defaults::str_isBooleanOldLayout + name;
std::string metaAttr;
switch (impl.schema())
{
case SupportedSchema::s_0000_00_00:
metaAttr = ADIOS2Defaults::str_isBooleanOldLayout + name;
break;
case SupportedSchema::s_2022_07_26:
metaAttr = ADIOS2Defaults::str_isBooleanNewLayout + name;
break;
}
/*
* In verbose mode, attributeInfo will yield a warning if not
* finding the requested attribute. Since we expect the attribute
Expand All @@ -1548,7 +1557,7 @@ namespace detail
*/
auto type = attributeInfo(
IO,
ADIOS2Defaults::str_isBooleanOldLayout + name,
metaAttr,
/* verbose = */ false);

if (type == determineDatatype<rep>())
Expand Down Expand Up @@ -1617,15 +1626,15 @@ namespace detail
}

template <int n, typename... Params>
Datatype OldAttributeReader::call(Params &&...)
Datatype AttributeReader::call(Params &&...)
{
throw std::runtime_error(
"[ADIOS2] Internal error: Unknown datatype while "
"trying to read an attribute.");
}

template <typename T>
void OldAttributeWriter::call(
void AttributeWriter::call(
ADIOS2IOHandlerImpl *impl,
Writable *writable,
const Parameter<Operation::WRITE_ATT> &parameters)
Expand Down Expand Up @@ -1731,8 +1740,17 @@ namespace detail
}
else if constexpr (std::is_same_v<T, bool>)
{
IO.DefineAttribute<bool_representation>(
ADIOS2Defaults::str_isBooleanOldLayout + fullName, 1);
switch (impl->schema())
{
case SupportedSchema::s_0000_00_00:
IO.DefineAttribute<bool_representation>(
ADIOS2Defaults::str_isBooleanOldLayout + fullName, 1);
break;
case SupportedSchema::s_2022_07_26:
IO.DefineAttribute<bool_representation>(
ADIOS2Defaults::str_isBooleanNewLayout + fullName, 1);
break;
}
auto representation = bool_repr::toRep(value);
auto attr = IO.DefineAttribute(
fullName,
Expand Down Expand Up @@ -1765,7 +1783,7 @@ namespace detail
}

template <int n, typename... Params>
void OldAttributeWriter::call(Params &&...)
void AttributeWriter::call(Params &&...)
{
throw std::runtime_error(
"[ADIOS2] Internal error: Unknown datatype while "
Expand Down

0 comments on commit d089c1d

Please sign in to comment.