/*========================================================================= Program: Visualization Toolkit Module: ADIOSScalar.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include #include #include #include "ADIOSScalar.h" namespace ADIOS { template void LoadScalarsFromStats(void* &ptr, ADIOS_VARINFO *v) { T* &ptrT = reinterpret_cast(ptr); ptrT = new T[v->sum_nblocks]; for(int i = 0; i < v->sum_nblocks; ++i) { ptrT[i] = *reinterpret_cast(v->statistics->blocks->mins[i]); } } //---------------------------------------------------------------------------- Scalar::Scalar(ADIOS_FILE *f, ADIOS_VARINFO *v) : VarInfo(f, v), Values(nullptr) { switch(this->Type) { case adios_byte: LoadScalarsFromStats(this->Values, v); break; case adios_short: LoadScalarsFromStats(this->Values, v); break; case adios_integer: LoadScalarsFromStats(this->Values, v); break; case adios_long: LoadScalarsFromStats(this->Values, v); break; case adios_unsigned_byte: LoadScalarsFromStats(this->Values, v); break; case adios_unsigned_short: LoadScalarsFromStats(this->Values, v); break; case adios_unsigned_integer: LoadScalarsFromStats(this->Values, v); break; case adios_unsigned_long: LoadScalarsFromStats(this->Values, v); break; case adios_real: LoadScalarsFromStats(this->Values, v); break; case adios_double: LoadScalarsFromStats(this->Values, v); break; case adios_complex: LoadScalarsFromStats >(this->Values, v); break; case adios_double_complex: LoadScalarsFromStats >(this->Values, v); break; default: // Unsupported data type break; } } //---------------------------------------------------------------------------- Scalar::~Scalar() { if(!this->Values) { return; } switch(this->Type) { case adios_byte: delete[] reinterpret_cast(this->Values); break; case adios_short: delete[] reinterpret_cast(this->Values); break; case adios_integer: delete[] reinterpret_cast(this->Values); break; case adios_long: delete[] reinterpret_cast(this->Values); break; case adios_unsigned_byte: delete[] reinterpret_cast(this->Values); break; case adios_unsigned_short: delete[] reinterpret_cast(this->Values); break; case adios_unsigned_integer: delete[] reinterpret_cast(this->Values); break; case adios_unsigned_long: delete[] reinterpret_cast(this->Values); break; case adios_real: delete[] reinterpret_cast(this->Values); break; case adios_double: delete[] reinterpret_cast(this->Values); break; case adios_complex: delete[] reinterpret_cast*>(this->Values); break; case adios_double_complex: delete[] reinterpret_cast*>(this->Values); break; default: break; } } } // End namespace ADIOS