VTK
ADIOSUtilities.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: ADIOSUtilities.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15#ifndef __ADIOSUtilities_h
16#define __ADIOSUtilities_h
17
18#include <stdint.h>
19
20#include <cstddef>
21
22#include <complex>
23#include <stdexcept>
24#include <string>
25
26#include <adios_types.h>
27
28namespace ADIOS
29{
30
31// Description:
32// Retrieve and parse error messages generated by the ADIOS write system
33class WriteError : public std::runtime_error
34{
35public:
36 WriteError(const std::string& msg = "");
37 virtual ~WriteError() throw() { }
38
39 // Description:
40 // Test error codes for expected values. An exception is thrown with the
41 // appropriate error message if detected
42 template<typename T>
43 static void TestEq(const T& expected, const T& actual,
44 const std::string& msg = "")
45 {
46 if(actual != expected)
47 {
48 throw WriteError(msg);
49 }
50 }
51
52 // Description:
53 // Test error codes for unexpected values. An exception is thrown with
54 // The appropriate error message if detected.
55 template<typename T>
56 static void TestNe(const T& notExpected, const T& actual,
57 const std::string& msg = "")
58 {
59 if(actual == notExpected)
60 {
61 throw WriteError(msg);
62 }
63 }
64};
65
66// Description:
67// Retrieve and parse error messages generated by the ADIOS read system
68class ReadError : public std::runtime_error
69{
70public:
71 ReadError(const std::string& msg = "");
72 virtual ~ReadError() throw() { }
73
74 // Description:
75 // Test error codes for expected values. An exception is thrown with the
76 // appropriate error message if detected
77 template<typename T>
78 static void TestEq(const T& expected, const T& actual,
79 const std::string& msg = "")
80 {
81 if(actual != expected)
82 {
83 throw ReadError(msg);
84 }
85 }
86
87 // Description:
88 // Test error codes for unexpected values. An exception is thrown with
89 // The appropriate error message if detected.
90 template<typename T>
91 static void TestNe(const T& notExpected, const T& actual,
92 const std::string& msg = "")
93 {
94 if(actual == notExpected)
95 {
96 throw ReadError(msg);
97 }
98 }
99};
100
101namespace Type
102{
103
104// Description:
105// Given a size in bytes, return the ADIOS signed integral type
106template<size_t S> ADIOS_DATATYPES SizeToInt();
107template<> ADIOS_DATATYPES SizeToInt<1>();
108template<> ADIOS_DATATYPES SizeToInt<2>();
109template<> ADIOS_DATATYPES SizeToInt<4>();
110template<> ADIOS_DATATYPES SizeToInt<8>();
111
112// Description:
113// Given a size in bytes, return the ADIOS unsigned integral type
114template<size_t S> ADIOS_DATATYPES SizeToUInt();
115template<> ADIOS_DATATYPES SizeToUInt<1>();
116template<> ADIOS_DATATYPES SizeToUInt<2>();
117template<> ADIOS_DATATYPES SizeToUInt<4>();
118template<> ADIOS_DATATYPES SizeToUInt<8>();
119
120// Description:
121// Map C and C++ primitive datatypes into ADIOS datatypes
122template<typename TN>
123ADIOS_DATATYPES NativeToADIOS();
124template<> ADIOS_DATATYPES NativeToADIOS<int8_t>();
125template<> ADIOS_DATATYPES NativeToADIOS<int16_t>();
126template<> ADIOS_DATATYPES NativeToADIOS<int32_t>();
127template<> ADIOS_DATATYPES NativeToADIOS<int64_t>();
128template<> ADIOS_DATATYPES NativeToADIOS<uint8_t>();
129template<> ADIOS_DATATYPES NativeToADIOS<uint16_t>();
130template<> ADIOS_DATATYPES NativeToADIOS<uint32_t>();
131template<> ADIOS_DATATYPES NativeToADIOS<uint64_t>();
132template<> ADIOS_DATATYPES NativeToADIOS<float>();
133template<> ADIOS_DATATYPES NativeToADIOS<double>();
134template<> ADIOS_DATATYPES NativeToADIOS<std::complex<float> >();
135template<> ADIOS_DATATYPES NativeToADIOS<std::complex<double> >();
136template<> ADIOS_DATATYPES NativeToADIOS<std::string>();
137
138// Description:
139// Map type sizes
140size_t SizeOf(ADIOS_DATATYPES ta);
141
142// Description:
143// Is the specified type an integer
144bool IsInt(ADIOS_DATATYPES ta);
145
146} // End namespace Type
147} // End namespace ADIOS
148#endif
149// VTK-HeaderTest-Exclude: ADIOSUtilities.h
static void TestEq(const T &expected, const T &actual, const std::string &msg="")
virtual ~ReadError()
static void TestNe(const T &notExpected, const T &actual, const std::string &msg="")
ReadError(const std::string &msg="")
static void TestNe(const T &notExpected, const T &actual, const std::string &msg="")
WriteError(const std::string &msg="")
virtual ~WriteError()
static void TestEq(const T &expected, const T &actual, const std::string &msg="")
ADIOS_DATATYPES NativeToADIOS< double >()
size_t SizeOf(ADIOS_DATATYPES ta)
ADIOS_DATATYPES SizeToUInt< 2 >()
ADIOS_DATATYPES NativeToADIOS< int32_t >()
ADIOS_DATATYPES SizeToInt< 2 >()
ADIOS_DATATYPES NativeToADIOS< uint16_t >()
ADIOS_DATATYPES SizeToUInt< 1 >()
ADIOS_DATATYPES NativeToADIOS< uint32_t >()
ADIOS_DATATYPES SizeToUInt< 8 >()
ADIOS_DATATYPES SizeToInt()
ADIOS_DATATYPES NativeToADIOS< float >()
ADIOS_DATATYPES NativeToADIOS< int16_t >()
ADIOS_DATATYPES SizeToUInt< 4 >()
ADIOS_DATATYPES NativeToADIOS< int8_t >()
ADIOS_DATATYPES NativeToADIOS()
ADIOS_DATATYPES SizeToUInt()
ADIOS_DATATYPES SizeToInt< 1 >()
ADIOS_DATATYPES NativeToADIOS< uint64_t >()
ADIOS_DATATYPES SizeToInt< 4 >()
ADIOS_DATATYPES NativeToADIOS< uint8_t >()
bool IsInt(ADIOS_DATATYPES ta)
ADIOS_DATATYPES NativeToADIOS< int64_t >()
ADIOS_DATATYPES SizeToInt< 8 >()
@ string
Definition: vtkX3D.h:490