Skip to content

Commit

Permalink
Merge pull request #3333 from eisenhauer/IOMods
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Sep 6, 2022
2 parents 773e4f1 + 42e7390 commit 9e305d8
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions source/adios2/core/IO.tcc
Expand Up @@ -126,10 +126,10 @@ Attribute<T> &IO::DefineAttribute(const std::string &name, const T &value,
auto itExistingAttribute = m_Attributes.find(globalName);
if (itExistingAttribute != m_Attributes.end())
{
if (helper::ValueToString(value) !=
itExistingAttribute->second->GetInfo()["Value"])
if (itExistingAttribute->second->m_Type == helper::GetDataType<T>())
{
if (itExistingAttribute->second->m_Type == helper::GetDataType<T>())
if (!itExistingAttribute->second->Equals(
static_cast<const void *>(&value), 1))
{
Attribute<T> &a =
static_cast<Attribute<T> &>(*itExistingAttribute->second);
Expand All @@ -144,16 +144,16 @@ Attribute<T> &IO::DefineAttribute(const std::string &name, const T &value,
globalName, itExistingAttribute->second.get(), Data);
}
}
else
{
helper::Throw<std::invalid_argument>(
"Core", "IO", "DefineAttribute",
"modifiable attribute " + globalName +
" has been defined with type " +
ToString(itExistingAttribute->second->m_Type) +
". Type cannot be changed to " +
ToString(helper::GetDataType<T>()));
}
}
else
{
helper::Throw<std::invalid_argument>(
"Core", "IO", "DefineAttribute",
"modifiable attribute " + globalName +
" has been defined with type " +
ToString(itExistingAttribute->second->m_Type) +
". Type cannot be changed to " +
ToString(helper::GetDataType<T>()));
}
return static_cast<Attribute<T> &>(*itExistingAttribute->second);
}
Expand Down Expand Up @@ -200,14 +200,10 @@ IO::DefineAttribute(const std::string &name, const T *array,
auto itExistingAttribute = m_Attributes.find(globalName);
if (itExistingAttribute != m_Attributes.end())
{
const std::string arrayValues(
"{ " +
helper::VectorToCSV(std::vector<T>(array, array + elements)) +
" }");

if (itExistingAttribute->second->GetInfo()["Value"] != arrayValues)
if (itExistingAttribute->second->m_Type == helper::GetDataType<T>())
{
if (itExistingAttribute->second->m_Type == helper::GetDataType<T>())
if (!itExistingAttribute->second->Equals(
static_cast<const void *>(array), elements))
{
Attribute<T> &a =
static_cast<Attribute<T> &>(*itExistingAttribute->second);
Expand All @@ -220,16 +216,16 @@ IO::DefineAttribute(const std::string &name, const T *array,
e.second->NotifyEngineAttribute(globalName, &a, Data);
}
}
else
{
helper::Throw<std::invalid_argument>(
"Core", "IO", "DefineAttribute",
"modifiable attribute " + globalName +
" has been defined with type " +
ToString(itExistingAttribute->second->m_Type) +
". Type cannot be changed to " +
ToString(helper::GetDataType<T>()));
}
}
else
{
helper::Throw<std::invalid_argument>(
"Core", "IO", "DefineAttribute",
"modifiable attribute " + globalName +
" has been defined with type " +
ToString(itExistingAttribute->second->m_Type) +
". Type cannot be changed to " +
ToString(helper::GetDataType<T>()));
}
return static_cast<Attribute<T> &>(*itExistingAttribute->second);
}
Expand Down

0 comments on commit 9e305d8

Please sign in to comment.