VTK
ADIOSScalar.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: ADIOSScalar.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 // .NAME ADIOSScalar - The utility class wrapping the ADIOS_VARINFO struct
16 
17 #ifndef _ADIOSScalar_h
18 #define _ADIOSScalar_h
19 #ifndef __VTK_WRAP__
20 #ifndef VTK_WRAPPING_CXX
21 
22 #include <string>
23 #include <vector>
24 
25 #include "ADIOSUtilities.h"
26 
27 #include "ADIOSVarInfo.h"
28 
29 //----------------------------------------------------------------------------
30 namespace ADIOS
31 {
32 
33 class Scalar : public VarInfo
34 {
35 public:
36  Scalar(ADIOS_FILE *f, ADIOS_VARINFO *v);
37  virtual ~Scalar(void);
38 
39  template<typename T>
40  const T& GetValue(size_t step, size_t block) const
41  {
42  ReadError::TestEq(this->Type, Type::NativeToADIOS<T>(), "Invalid type");
43 
44  StepBlock* idx = this->GetNewestBlockIndex(step, block);
45  ReadError::TestNe<StepBlock*>(nullptr, idx, "Variable not available");
46 
47  return reinterpret_cast<const T*>(this->Values)[idx->BlockId];
48  }
49 
50 protected:
51  void *Values;
52 };
53 
54 } // End namespace ADIOS
55 #endif
56 #endif
57 #endif // _ADIOSScalar_h
58 // VTK-HeaderTest-Exclude: ADIOSScalar.h
Scalar(ADIOS_FILE *f, ADIOS_VARINFO *v)
void * Values
Definition: ADIOSScalar.h:51
static void TestEq(const T &expected, const T &actual, const std::string &msg="")
virtual ~Scalar(void)
const T & GetValue(size_t step, size_t block) const
Definition: ADIOSScalar.h:40
ADIOS_DATATYPES Type
Definition: ADIOSVarInfo.h:59
StepBlock * GetNewestBlockIndex(size_t step, size_t pid) const