Newer
Older
Atkins, Charles Vernon
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* 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_ */