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 
20 #include <string>
21 #include <vector>
22 
23 #include "ADIOSUtilities.h"
24 
25 #include "ADIOSVarInfo.h"
26 
27 //----------------------------------------------------------------------------
28 namespace ADIOS
29 {
30 
31 class Scalar : public VarInfo
32 {
33 public:
34  Scalar(ADIOS_FILE *f, ADIOS_VARINFO *v);
35  virtual ~Scalar(void);
36 
37  template<typename T>
38  const T& GetValue(size_t step, size_t block) const
39  {
40  ReadError::TestEq(this->Type, Type::NativeToADIOS<T>(), "Invalid type");
41 
42  StepBlock* idx = this->GetNewestBlockIndex(step, block);
43  ReadError::TestNe<StepBlock*>(NULL, idx, "Variable not available");
44 
45  return reinterpret_cast<const T*>(this->Values)[idx->BlockId];
46  }
47 
48 protected:
49  void *Values;
50 };
51 
52 } // End namespace ADIOS
53 #endif // _ADIOSScalar_h
54 // VTK-HeaderTest-Exclude: ADIOSScalar.h
Scalar(ADIOS_FILE *f, ADIOS_VARINFO *v)
void * Values
Definition: ADIOSScalar.h:49
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:38
ADIOS_DATATYPES Type
Definition: ADIOSVarInfo.h:57
StepBlock * GetNewestBlockIndex(size_t step, size_t pid) const