Skip to content

Commit

Permalink
rmvar: specialize Variable<Compound>, VariableCompound is now only an…
Browse files Browse the repository at this point in the history
… alias
  • Loading branch information
germasch committed Feb 27, 2019
1 parent 60f1201 commit a62ecd9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
4 changes: 4 additions & 0 deletions source/adios2/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ using std::uint64_t;
using cfloat = std::complex<float>;
using cdouble = std::complex<double>;

// Compound is never actually defined, it's just used to template with, in
// particular Variable<Compound>.
class Compound;

// Limit, using uint64_t to make it portable
constexpr uint64_t MaxU64 = std::numeric_limits<uint64_t>::max();
constexpr size_t MaxSizeT = std::numeric_limits<size_t>::max();
Expand Down
17 changes: 8 additions & 9 deletions source/adios2/core/VariableCompound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ namespace adios2
namespace core
{

VariableCompound::VariableCompound(const std::string &name,
const size_t structSize, const Dims &shape,
const Dims &start, const Dims &count,
const bool constantDims,
const bool debugMode)
: VariableBase(name, "compound", structSize, shape, start, count, constantDims,
debugMode)
Variable<Compound>::Variable(const std::string &name, const size_t structSize,
const Dims &shape, const Dims &start,
const Dims &count, const bool constantDims,
const bool debugMode)
: VariableBase(name, "compound", structSize, shape, start, count,
constantDims, debugMode)
{
}

#define declare_template_instantiation(T) \
template void VariableCompound::InsertMember<T>(const std::string &, \
const size_t);
template void Variable<Compound>::InsertMember<T>(const std::string &, \
const size_t);
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation

Expand Down
20 changes: 13 additions & 7 deletions source/adios2/core/VariableCompound.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#ifndef ADIOS2_CORE_VARIABLECOMPOUND_H_
#define ADIOS2_CORE_VARIABLECOMPOUND_H_

#include "VariableBase.h"
// FIXME, VariableCompound is now also an alias for Variable<Compound>, so
// arguably this should be all merged into Variable.{h,tcc,cpp}
#include "Variable.h"

#include "adios2/ADIOSMacros.h"

Expand All @@ -24,7 +26,8 @@ namespace core
* @param Base (parent) class for template derived (child) class CVariable.
* Required to put CVariable objects in STL containers.
*/
class VariableCompound : public VariableBase
template <>
class Variable<Compound> : public VariableBase
{

public:
Expand All @@ -41,11 +44,12 @@ class VariableCompound : public VariableBase
/** vector of primitve element types defining compound struct */
std::vector<Element> m_Elements;

VariableCompound(const std::string &name, const size_t structSize,
const Dims &shape, const Dims &start, const Dims &count,
const bool constantDims, const bool debugMode);
Variable();
Variable(const std::string &name, const size_t structSize,
const Dims &shape, const Dims &start, const Dims &count,
const bool constantDims, const bool debugMode);

~VariableCompound() = default;
~Variable() = default;

/**
* Inserts an Element into the compound struct definition
Expand All @@ -58,11 +62,13 @@ class VariableCompound : public VariableBase

// Explicit declaration of the public template methods
#define declare_template_instantiation(T) \
extern template void VariableCompound::InsertMember<T>( \
extern template void Variable<Compound>::InsertMember<T>( \
const std::string &, const size_t);
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation

using VariableCompound = Variable<Compound>;

} // end namespace core
} // end namespace adios2

Expand Down
4 changes: 2 additions & 2 deletions source/adios2/core/VariableCompound.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace core
{

template <class T>
void VariableCompound::InsertMember(const std::string &name,
const size_t offset)
void Variable<Compound>::InsertMember(const std::string &name,
const size_t offset)
{
m_Elements.push_back(Element{name, helper::GetType<T>(), offset});
}
Expand Down

0 comments on commit a62ecd9

Please sign in to comment.