Newer
Older
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
/*
* VariableBase.h
*
* Created on: Feb 20, 2017
* Author: wfg
*/
#ifndef VARIABLEBASE_H_
#define VARIABLEBASE_H_
/// \cond EXCLUDE_FROM_DOXYGEN
#include <vector>
#include <string>
/// \endcond
#include "functions/adiosFunctions.h" //GetTotalSize
#include "functions/adiosTemplates.h" //GetType<T>
namespace adios
{
using Dims = std::vector<std::size_t>;
class VariableBase
{
public:
const std::string m_Name; ///< variable name
const std::string m_Type; ///< variable type
const std::size_t m_ElementSize; ///< Variable -> sizeof(T), VariableCompound -> from constructor
bool m_IsScalar = false;
const bool m_IsDimension = false;
VariableBase( const std::string name, const std::string type, const std::size_t elementSize,
const Dims dimensions, const Dims globalDimensions, const Dims globalOffsets,
const bool debugMode ):
m_Name{ name },
m_Type{ type },
m_ElementSize{ elementSize },
m_Dimensions{ dimensions },
m_GlobalDimensions{ globalDimensions },
m_GlobalOffsets{ globalOffsets },
m_DebugMode{ debugMode }
{ }
virtual ~VariableBase( )
{ }
std::size_t DimensionsSize( ) const noexcept
{
return m_Dimensions.size();
}
/**
* Returns the payload size in bytes
* @return TotalSize * sizeof(T)
*/
std::size_t PayLoadSize( ) const noexcept
{
return GetTotalSize( m_Dimensions ) * m_ElementSize;
}
/**
* Returns the total size
* @return number of elements
*/
std::size_t TotalSize( ) const noexcept
{
return GetTotalSize( m_Dimensions );
}
//protected: off for now
Dims m_Dimensions; ///< array of local dimensions
Dims m_GlobalDimensions; ///< array of global dimensions
Dims m_GlobalOffsets; ///< array of global offsets
const bool m_DebugMode = false;
};
}
#endif /* VARIABLEBASE_H_ */