Skip to content
Snippets Groups Projects
Commit fa4782d3 authored by wfg's avatar wfg
Browse files

Merge branch 'master' of https://github.com/ornladios/ADIOS2.git

Conflicts:
	include/ADIOS.h
parents 83fbcc4c 738c37d7
No related branches found
No related tags found
2 merge requests!48Utilities,!45Code structure changes and syntax
This diff is collapsed.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
/// \endcond /// \endcond
#include "ADIOS.h" #include "ADIOS.h"
#include "ADIOS.tcc"
#include "functions/adiosFunctions.h" #include "functions/adiosFunctions.h"
......
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* ADIOS.tcc
* This contains the template specialization implementations for the ADIOS
* class
*/
#ifndef ADIOS_TCC_
#define ADIOS_TCC_
#include <complex>
#include <map>
#include <memory> //std::shared_ptr
#include <ostream>
#include <set>
#include <string>
#include <vector>
#include "ADIOS.h"
#include "ADIOSMacros.h"
namespace adios
{
// -----------------------------------------------------------------------------
// template specializations of GetVarMap helper function
// -----------------------------------------------------------------------------
template <>
std::map<unsigned int, Variable<char>> &ADIOS::GetVarMap()
{
return m_Char;
}
template <>
std::map<unsigned int, Variable<unsigned char>> &ADIOS::GetVarMap()
{
return m_UChar;
}
template <>
std::map<unsigned int, Variable<short>> &ADIOS::GetVarMap()
{
return m_Short;
}
template <>
std::map<unsigned int, Variable<unsigned short>> &ADIOS::GetVarMap()
{
return m_UShort;
}
template <>
std::map<unsigned int, Variable<int>> &ADIOS::GetVarMap()
{
return m_Int;
}
template <>
std::map<unsigned int, Variable<unsigned int>> &ADIOS::GetVarMap()
{
return m_UInt;
}
template <>
std::map<unsigned int, Variable<long int>> &ADIOS::GetVarMap()
{
return m_LInt;
}
template <>
std::map<unsigned int, Variable<unsigned long int>> &ADIOS::GetVarMap()
{
return m_ULInt;
}
template <>
std::map<unsigned int, Variable<long long int>> &ADIOS::GetVarMap()
{
return m_LLInt;
}
template <>
std::map<unsigned int, Variable<unsigned long long int>> &ADIOS::GetVarMap()
{
return m_ULLInt;
}
template <>
std::map<unsigned int, Variable<float>> &ADIOS::GetVarMap()
{
return m_Float;
}
template <>
std::map<unsigned int, Variable<double>> &ADIOS::GetVarMap()
{
return m_Double;
}
template <>
std::map<unsigned int, Variable<long double>> &ADIOS::GetVarMap()
{
return m_LDouble;
}
template <>
std::map<unsigned int, Variable<std::complex<float>>> &ADIOS::GetVarMap()
{
return m_CFloat;
}
template <>
std::map<unsigned int, Variable<std::complex<double>>> &ADIOS::GetVarMap()
{
return m_CDouble;
}
template <>
std::map<unsigned int, Variable<std::complex<long double>>> &ADIOS::GetVarMap()
{
return m_CLDouble;
}
// -----------------------------------------------------------------------------
// template specializations of DefineVariable:
// -----------------------------------------------------------------------------
template <typename T>
Variable<T> &
ADIOS::DefineVariable(const std::string &name, const Dims dimensions,
const Dims globalDimensions, const Dims globalOffsets)
{
auto &varMap = GetVarMap<T>();
CheckVariableInput(name, dimensions);
const unsigned int size = varMap.size();
varMap.emplace(size, Variable<T>(name, dimensions, globalDimensions,
globalOffsets, m_DebugMode));
m_Variables.emplace(name, std::make_pair(GetType<T>(), size));
return varMap.at(size);
}
#define instantiate_specialization(T) \
template Variable<T> &ADIOS::DefineVariable<T>( \
const std::string &, const Dims, const Dims, const Dims);
ADIOS_FOREACH_TYPE_1ARG(instantiate_specialization)
#undef instantiate_specialization
// -----------------------------------------------------------------------------
// template specializations of DefineVariable:
// -----------------------------------------------------------------------------
template <class T>
unsigned int ADIOS::GetVariableIndex(const std::string &name)
{
auto itVariable = m_Variables.find(name);
CheckVariableName(
itVariable, name,
"in call to GetVariable<" + GetType<T>() +
">, or call to GetVariableCompound if <T> = <compound>\n");
return itVariable->second.second;
}
// Get template specialization
template <typename T>
Variable<T> &ADIOS::GetVariable(const std::string &name)
{
return GetVarMap<T>().at(GetVariableIndex<T>(name));
}
#define instantiate_specialization(T) \
template Variable<T> &ADIOS::GetVariable<T>(const std::string &);
ADIOS_FOREACH_TYPE_1ARG(instantiate_specialization)
#undef instantiate_specialization
} // end namespace adios
#endif /* ADIOS_TCC_ */
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* ADIOSMacros.h
* This contains a set of helper macros used internally
*/
#ifndef ADIOSMACROS_H
#define ADIOSMACROS_H
// The ADIOS_FOREACH_TYPE_1ARG macro assumes the given argument is a macro which
// takes a single argument that is a type and then inserts the given MACRO for
// each of the known primitive types
//
// An example of this might be to instantiate a template function for each
// known type. For example:
//
// template<typename T> int foo() { /* some implementation of foo */ }
//
// #define instantiate_foo(T) template int foo<T>();
// ADIOS_FOREACH_TYPE_1ARG(instantiate_foo)
// #undef instantiate_foo
//
#define ADIOS_FOREACH_TYPE_1ARG(MACRO) \
MACRO(char) \
MACRO(unsigned char) \
MACRO(short) \
MACRO(unsigned short) \
MACRO(int) \
MACRO(unsigned int) \
MACRO(long int) \
MACRO(unsigned long int) \
MACRO(long long int) \
MACRO(unsigned long long int) \
MACRO(float) \
MACRO(double) \
MACRO(long double) \
MACRO(std::complex<float>) \
MACRO(std::complex<double>) \
MACRO(std::complex<long double>)
#endif // ADIOSMACROS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment