44 #ifndef _INCLUDED_Field3D_SparseDataReader_H_ 45 #define _INCLUDED_Field3D_SparseDataReader_H_ 67 template <
class Data_T>
86 void readBlockList(
int idx,
const std::vector<Data_T*>& memoryList);
106 template <
class Data_T>
121 throw OpenDataSetException(
"Couldn't open data set: " +
k_dataStr);
127 throw GetDataSpaceException(
"Couldn't get data space");
129 throw GetDataTypeException(
"Couldn't get data type");
139 throw FileIntegrityException(
"Block length mismatch in " 142 if (dims[0] != static_cast<hsize_t>(occupiedBlocks))
143 throw FileIntegrityException(
"Block count mismatch in " 149 template <
class Data_T>
165 offset, NULL, count, NULL);
167 throw ReadHyperSlabException(
"Couldn't select slab " +
168 boost::lexical_cast<std::string>(idx));
173 H5P_DEFAULT, &result);
178 template <
class Data_T>
180 (
int idxLo,
const std::vector<Data_T*>& memoryList)
191 count[0] = memoryList.size();
195 offset, NULL, count, NULL);
197 throw ReadHyperSlabException(
"Couldn't select slab " +
198 boost::lexical_cast<std::string>(idxLo));
205 memDims[0] = memoryList.size();
207 localMemDataSpace.
create(H5S_SIMPLE);
208 H5Sset_extent_simple(localMemDataSpace.
id(), 2, memDims, NULL);
212 int bytesPerValue = 0;
215 if (t == H5T_NATIVE_CHAR)
217 else if (t == H5T_NATIVE_SHORT)
219 else if (t == H5T_NATIVE_FLOAT)
221 else if (t == H5T_NATIVE_DOUBLE)
225 int dim =
sizeof(Data_T) / bytesPerValue;
230 localMemDataSpace.
id(),
232 H5P_DEFAULT, &bigblock[0]);
235 throw Hdf5DataReadException(
"Couldn't read slab " +
236 boost::lexical_cast<std::string>(idxLo));
240 for (
size_t i = 0; i < memoryList.size(); ++i) {
241 memcpy(memoryList[i],
void open(hid_t dataset_id)
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Hdf5Util::H5ScopedScreate m_memDataSpace
Contains utility functions and classes for Hdf5 files.
Scoped object - opens a dataset on creation and closes it on destruction.
Namespace for Exception objects.
SparseDataReader(hid_t location, int valuesPerBlock, int occupiedBlocks)
Constructor. Requires knowledge of the Hdf5 location where data is stored.
Scoped object - opens a dataset on creation and closes it on destruction.
Contains various utility functions for Hdf5.
Hdf5Util::H5ScopedDget_space m_fileDataSpace
void open(hid_t dataset_id)
void readBlock(int idx, Data_T &result)
Reads a block, storing the data in result, which is assumed to contain enough room for m_valuesPerBlo...
const std::string k_dataStr
This class gets used by SparseFieldIO and SparseFileManager to read the block data. On creation it will open the data set and not close it until the object is destroyed.
void open(hid_t parentLocation, const std::string &name, hid_t dapl_id)
Hdf5Util::H5ScopedDget_type m_dataType
void readBlockList(int idx, const std::vector< Data_T *> &memoryList)
Reads a series of blocks, storing each block of data in memoryList, which is assumed to contain enoug...
Scoped object - creates a dataspace on creation and closes it on destruction.
Hdf5Util::H5ScopedDopen m_dataSet
hid_t id() const
Query the hid_t value.
void create(H5S_class_t type)
Scoped object - opens a dataset on creation and closes it on destruction.