From b51eafe0ebb14311fe8025718c44e008f5a09c55 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Mon, 25 Feb 2019 10:43:00 -0500 Subject: [PATCH] cxx11/Attribute: use regular templates --- bindings/CXX11/cxx11/Attribute.cpp | 56 ++------------------------ bindings/CXX11/cxx11/Attribute.tcc | 64 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 52 deletions(-) create mode 100644 bindings/CXX11/cxx11/Attribute.tcc diff --git a/bindings/CXX11/cxx11/Attribute.cpp b/bindings/CXX11/cxx11/Attribute.cpp index 5791c12e7b..efd98e4286 100644 --- a/bindings/CXX11/cxx11/Attribute.cpp +++ b/bindings/CXX11/cxx11/Attribute.cpp @@ -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::Attribute(core::Attribute *attribute) \ - : m_Attribute(attribute) \ - { \ - } \ - \ - template <> \ - Attribute::operator bool() const noexcept \ - { \ - return (m_Attribute == nullptr) ? false : true; \ - } \ - \ - template <> \ - std::string Attribute::Name() const \ - { \ - helper::CheckForNullptr(m_Attribute, \ - "in call to Attribute::Name()"); \ - return m_Attribute->m_Name; \ - } \ - \ - template <> \ - std::string Attribute::Type() const \ - { \ - helper::CheckForNullptr(m_Attribute, \ - "in call to Attribute::Type()"); \ - return m_Attribute->m_Type; \ - } \ - \ - template <> \ - std::vector Attribute::Data() const \ - { \ - helper::CheckForNullptr(m_Attribute, \ - "in call to Attribute::Data()"); \ - \ - if (m_Attribute->m_IsSingleValue) \ - { \ - return std::vector{m_Attribute->m_DataSingleValue}; \ - } \ - else \ - { \ - return reinterpret_cast &>( \ - m_Attribute->m_DataArray); \ - } \ - } +#define declare_template_instantiation(T) template class Attribute; -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 diff --git a/bindings/CXX11/cxx11/Attribute.tcc b/bindings/CXX11/cxx11/Attribute.tcc new file mode 100644 index 0000000000..6a0fab2f1a --- /dev/null +++ b/bindings/CXX11/cxx11/Attribute.tcc @@ -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 godoywf@ornl.gov + */ + +#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 +Attribute::Attribute(core::Attribute *attribute) +: m_Attribute(attribute) +{ +} + +template +Attribute::operator bool() const noexcept +{ + return (m_Attribute == nullptr) ? false : true; +} + +template +std::string Attribute::Name() const +{ + helper::CheckForNullptr(m_Attribute, "in call to Attribute::Name()"); + return m_Attribute->m_Name; +} + +template +std::string Attribute::Type() const +{ + helper::CheckForNullptr(m_Attribute, "in call to Attribute::Type()"); + return m_Attribute->m_Type; +} + +template +std::vector Attribute::Data() const +{ + helper::CheckForNullptr(m_Attribute, "in call to Attribute::Data()"); + + if (m_Attribute->m_IsSingleValue) + { + return std::vector{m_Attribute->m_DataSingleValue}; + } + else + { + return reinterpret_cast &>(m_Attribute->m_DataArray); + } +} + +} // end namespace adios2 + +#endif /* ADIOS2_BINDINGS_CXX11_CXX11_ATTRIBUTE_TCC_ */