Skip to content
Snippets Groups Projects
ADIOS.tcc 3.5 KiB
Newer Older
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * ADIOS.tcc
 *   This contains the template specializatios for the ADIOS class
#ifndef ADIOS_TCC_
#define ADIOS_TCC_

#include "ADIOS.h"
#include "ADIOSMacros.h"

namespace adios
{

// -----------------------------------------------------------------------------
// template specializations of GetVarMap helper function
// -----------------------------------------------------------------------------

template <>
wfg's avatar
wfg committed
std::map<unsigned int, Variable<char>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<unsigned char>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<short>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<unsigned short>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<int>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<unsigned int>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<long int>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<unsigned long int>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<long long int>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<unsigned long long int>> &
ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<float>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<double>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<long double>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<std::complex<float>>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<std::complex<double>>> &ADIOS::GetVariableMap()
wfg's avatar
wfg committed
std::map<unsigned int, Variable<std::complex<long double>>> &
ADIOS::GetVariableMap()
{
    return m_CLDouble;
}

// -----------------------------------------------------------------------------

template <typename T>
Variable<T> &
wfg's avatar
wfg committed
ADIOS::DefineVariable(const std::string &name, const Dims globalDimensions,
                      const Dims localDimensions, const Dims offsets)
{
    auto &variableMap = GetVariableMap<T>();
    CheckVariableInput(name, globalDimensions);
    const unsigned int size = variableMap.size();
    variableMap.emplace(size,
                        Variable<T>(name, globalDimensions, localDimensions,
                                    offsets, m_DebugMode));
    m_Variables.emplace(name, std::make_pair(GetType<T>(), size));
wfg's avatar
wfg committed
    return variableMap.at(size);
}

// -----------------------------------------------------------------------------

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;
}

template <typename T>
Variable<T> &ADIOS::GetVariable(const std::string &name)
{
wfg's avatar
wfg committed
    return GetVariableMap<T>().at(GetVariableIndex<T>(name));