本文整理汇总了C++中Dimensions::getPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ Dimensions::getPointer方法的具体用法?C++ Dimensions::getPointer怎么用?C++ Dimensions::getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dimensions
的用法示例。
在下文中一共展示了Dimensions::getPointer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeAttribute
void DCAttribute::writeAttribute(const char* name, const hid_t type, hid_t parent,
uint32_t ndims, const Dimensions dims, const void* src)
throw (DCException)
{
hid_t attr = -1;
if (H5Aexists(parent, name))
attr = H5Aopen(parent, name, H5P_DEFAULT);
else
{
hid_t dsp;
if( ndims == 1 && dims.getScalarSize() == 1 )
dsp = H5Screate(H5S_SCALAR);
else
dsp = H5Screate_simple( ndims, dims.getPointer(), dims.getPointer() );
attr = H5Acreate(parent, name, type, dsp, H5P_DEFAULT, H5P_DEFAULT);
H5Sclose(dsp);
}
if (attr < 0)
throw DCException(getExceptionString(name, "Attribute could not be opened or created"));
if (H5Awrite(attr, type, src) < 0)
{
H5Aclose(attr);
throw DCException(getExceptionString(name, "Attribute could not be written"));
}
H5Aclose(attr);
}
示例2: createReference
void DCDataSet::createReference(hid_t refGroup,
hid_t srcGroup,
DCDataSet &srcDataSet,
Dimensions count,
Dimensions offset,
Dimensions stride)
throw (DCException)
{
if (opened)
throw DCException(getExceptionString("createReference: dataset is already open"));
if (checkExistence && H5Lexists(refGroup, name.c_str(), H5P_LINK_ACCESS_DEFAULT))
throw DCException(getExceptionString("createReference: this reference already exists"));
getLogicalSize().set(count);
this->ndims = srcDataSet.getNDims();
count.swapDims(this->ndims);
offset.swapDims(this->ndims);
stride.swapDims(this->ndims);
// select region hyperslab in source dataset
if (H5Sselect_hyperslab(srcDataSet.getDataSpace(), H5S_SELECT_SET,
offset.getPointer(), stride.getPointer(),
count.getPointer(), NULL) < 0 ||
H5Sselect_valid(srcDataSet.getDataSpace()) <= 0)
throw DCException(getExceptionString("createReference: failed to select hyperslap for reference"));
if (H5Rcreate(®ionRef, srcGroup, srcDataSet.getName().c_str(), H5R_DATASET_REGION,
srcDataSet.getDataSpace()) < 0)
throw DCException(getExceptionString("createReference: failed to create region reference"));
hsize_t ndims = 1;
dataspace = H5Screate_simple(1, &ndims, NULL);
if (dataspace < 0)
throw DCException(getExceptionString("createReference: failed to create dataspace for reference"));
dataset = H5Dcreate(refGroup, name.c_str(), H5T_STD_REF_DSETREG,
dataspace, H5P_DEFAULT, dsetProperties, H5P_DEFAULT);
if (dataset < 0)
throw DCException(getExceptionString("createReference: failed to create dataset for reference"));
if (H5Dwrite(dataset, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL,
dsetWriteProperties, ®ionRef) < 0)
throw DCException(getExceptionString("createReference: failed to write reference"));
isReference = true;
opened = true;
}
示例3: write
void DCDataSet::write(Dimensions srcBuffer, Dimensions srcStride,
Dimensions srcOffset, Dimensions srcData,
Dimensions dstOffset, const void* data)
throw (DCException)
{
log_msg(2, "DCDataSet::write (%s)", name.c_str());
if (!opened)
throw DCException(getExceptionString("write: Dataset has not been opened/created"));
log_msg(3,
" ndims = %llu\n"
" logical_size = %s\n"
" physical_size = %s\n"
" src_buffer = %s\n"
" src_stride = %s\n"
" src_data = %s\n"
" src_offset = %s\n"
" dst_offset = %s\n",
(long long unsigned) ndims,
getLogicalSize().toString().c_str(),
getPhysicalSize().toString().c_str(),
srcBuffer.toString().c_str(),
srcStride.toString().c_str(),
srcData.toString().c_str(),
srcOffset.toString().c_str(),
dstOffset.toString().c_str());
// swap dimensions if necessary
srcBuffer.swapDims(ndims);
srcStride.swapDims(ndims);
srcData.swapDims(ndims);
srcOffset.swapDims(ndims);
dstOffset.swapDims(ndims);
// dataspace to read from
hid_t dsp_src;
if (getLogicalSize().getScalarSize() != 0)
{
dsp_src = H5Screate_simple(ndims, srcBuffer.getPointer(), NULL);
if (dsp_src < 0)
throw DCException(getExceptionString("write: Failed to create source dataspace"));
if (H5Sselect_hyperslab(dsp_src, H5S_SELECT_SET, srcOffset.getPointer(),
srcStride.getPointer(), srcData.getPointer(), NULL) < 0 ||
H5Sselect_valid(dsp_src) <= 0)
throw DCException(getExceptionString("write: Invalid source hyperslap selection"));
if (srcData.getScalarSize() == 0)
H5Sselect_none(dsp_src);
// dataspace to write to
if (H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, dstOffset.getPointer(),
NULL, srcData.getPointer(), NULL) < 0 ||
H5Sselect_valid(dataspace) <= 0)
throw DCException(getExceptionString("write: Invalid target hyperslap selection"));
if (!data || (srcData.getScalarSize() == 0))
{
H5Sselect_none(dataspace);
data = NULL;
}
// write data to the dataset
if (H5Dwrite(dataset, this->datatype, dsp_src, dataspace, dsetWriteProperties, data) < 0)
throw DCException(getExceptionString("write: Failed to write dataset"));
H5Sclose(dsp_src);
}
}
示例4: read
void DCDataSet::read(Dimensions dstBuffer,
Dimensions dstOffset,
Dimensions srcSize,
Dimensions srcOffset,
Dimensions& sizeRead,
uint32_t& srcNDims,
void* dst)
throw (DCException)
{
log_msg(2, "DCDataSet::read (%s)", name.c_str());
if (!opened)
throw DCException(getExceptionString("read: Dataset has not been opened/created"));
if (dstBuffer.getScalarSize() == 0)
dstBuffer.set(srcSize);
// dst buffer is allowed to be NULL
// in this case, only the size of the dataset is returned
// if the dataset is empty, return just its size as there is nothing to read
if ((dst != NULL) && (getNDims() > 0))
{
log_msg(3,
" ndims = %llu\n"
" logical_size = %s\n"
" physical_size = %s\n"
" dstBuffer = %s\n"
" dstOffset = %s\n"
" srcSize = %s\n"
" srcOffset = %s\n",
(long long unsigned) ndims,
getLogicalSize().toString().c_str(),
getPhysicalSize().toString().c_str(),
dstBuffer.toString().c_str(),
dstOffset.toString().c_str(),
srcSize.toString().c_str(),
srcOffset.toString().c_str());
dstBuffer.swapDims(ndims);
dstOffset.swapDims(ndims);
srcSize.swapDims(ndims);
srcOffset.swapDims(ndims);
hid_t dst_dataspace = H5Screate_simple(ndims, dstBuffer.getPointer(), NULL);
if (dst_dataspace < 0)
throw DCException(getExceptionString("read: Failed to create target dataspace"));
if (H5Sselect_hyperslab(dst_dataspace, H5S_SELECT_SET, dstOffset.getPointer(), NULL,
srcSize.getPointer(), NULL) < 0 ||
H5Sselect_valid(dst_dataspace) <= 0)
throw DCException(getExceptionString("read: Target dataspace hyperslab selection is not valid!"));
if (H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, srcOffset.getPointer(), NULL,
srcSize.getPointer(), NULL) < 0 ||
H5Sselect_valid(dataspace) <= 0)
throw DCException(getExceptionString("read: Source dataspace hyperslab selection is not valid!"));
if (srcSize.getScalarSize() == 0)
H5Sselect_none(dataspace);
if (H5Dread(dataset, this->datatype, dst_dataspace, dataspace, dsetReadProperties, dst) < 0)
throw DCException(getExceptionString("read: Failed to read dataset"));
H5Sclose(dst_dataspace);
srcSize.swapDims(ndims);
}
// swap dimensions if necessary
sizeRead.set(srcSize);
srcNDims = this->ndims;
log_msg(3, " returns ndims = %llu", (long long unsigned) ndims);
log_msg(3, " returns sizeRead = %s", sizeRead.toString().c_str());
}