Skip to content

Commit

Permalink
Merge pull request #1225 from germasch/cleanup
Browse files Browse the repository at this point in the history
Cleanup: use regular templates in .tcc for Attribute, Variable
  • Loading branch information
williamfgc authored Feb 25, 2019
2 parents 68d6d72 + b51eafe commit ab0219e
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 370 deletions.
56 changes: 4 additions & 52 deletions bindings/CXX11/cxx11/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,14 @@
*/

#include "Attribute.h"

#include "adios2/ADIOSMacros.h"
#include "adios2/core/Attribute.h"
#include "adios2/helper/adiosFunctions.h"
#include "Attribute.tcc"

namespace adios2
{

#define declare_type(T) \
\
template <> \
Attribute<T>::Attribute(core::Attribute<IOType> *attribute) \
: m_Attribute(attribute) \
{ \
} \
\
template <> \
Attribute<T>::operator bool() const noexcept \
{ \
return (m_Attribute == nullptr) ? false : true; \
} \
\
template <> \
std::string Attribute<T>::Name() const \
{ \
helper::CheckForNullptr(m_Attribute, \
"in call to Attribute<T>::Name()"); \
return m_Attribute->m_Name; \
} \
\
template <> \
std::string Attribute<T>::Type() const \
{ \
helper::CheckForNullptr(m_Attribute, \
"in call to Attribute<T>::Type()"); \
return m_Attribute->m_Type; \
} \
\
template <> \
std::vector<T> Attribute<T>::Data() const \
{ \
helper::CheckForNullptr(m_Attribute, \
"in call to Attribute<T>::Data()"); \
\
if (m_Attribute->m_IsSingleValue) \
{ \
return std::vector<T>{m_Attribute->m_DataSingleValue}; \
} \
else \
{ \
return reinterpret_cast<std::vector<T> &>( \
m_Attribute->m_DataArray); \
} \
}
#define declare_template_instantiation(T) template class Attribute<T>;

ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_type)
#undef declare_type
ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation

} // end namespace adios2
64 changes: 64 additions & 0 deletions bindings/CXX11/cxx11/Attribute.tcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* Attribute.tcc :
*
* Created on: Jun 4, 2018
* Author: William F Godoy [email protected]
*/

#ifndef ADIOS2_BINDINGS_CXX11_CXX11_ATTRIBUTE_TCC_
#define ADIOS2_BINDINGS_CXX11_CXX11_ATTRIBUTE_TCC_

#include "Attribute.h"

#include "adios2/helper/adiosFunctions.h"

namespace adios2
{

template <class T>
Attribute<T>::Attribute(core::Attribute<IOType> *attribute)
: m_Attribute(attribute)
{
}

template <class T>
Attribute<T>::operator bool() const noexcept
{
return (m_Attribute == nullptr) ? false : true;
}

template <class T>
std::string Attribute<T>::Name() const
{
helper::CheckForNullptr(m_Attribute, "in call to Attribute<T>::Name()");
return m_Attribute->m_Name;
}

template <class T>
std::string Attribute<T>::Type() const
{
helper::CheckForNullptr(m_Attribute, "in call to Attribute<T>::Type()");
return m_Attribute->m_Type;
}

template <class T>
std::vector<T> Attribute<T>::Data() const
{
helper::CheckForNullptr(m_Attribute, "in call to Attribute<T>::Data()");

if (m_Attribute->m_IsSingleValue)
{
return std::vector<T>{m_Attribute->m_DataSingleValue};
}
else
{
return reinterpret_cast<std::vector<T> &>(m_Attribute->m_DataArray);
}
}

} // end namespace adios2

#endif /* ADIOS2_BINDINGS_CXX11_CXX11_ATTRIBUTE_TCC_ */
Loading

0 comments on commit ab0219e

Please sign in to comment.