CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
h5_dataset.cc
Go to the documentation of this file.
1// -*- C++ -*-
12#include "h5_dataset.h"
13
14namespace CNORXZ
15{
16 namespace hdf5
17 {
19 ContentBase(name, _parent)
20 {
21 if(exists()){
22 open();
23 }
24 }
25
27 {
28 this->close();
29 }
30
32 {
33 return ContentType::DSET;
34 }
35
36 bool Dataset::ro() const
37 {
38 return mParent->ro();
39 }
40
42 {
43 if(mId == 0 and exists()){
44 mId = H5Dopen(mParent->id(), mName.c_str(), H5P_DEFAULT);
46
51
53 for(SizeT i = 0; i != ndims; ++i){
55 }
57 }
58 return *this;
59 }
60
62 {
63 if(mId != 0){
67 mId = 0;
68 }
69 return *this;
70 }
71
73 {
74 return mParent->path() + "/" + mName;
75 }
76
78 {
79 return mParent->filename();
80 }
81
82 bool Dataset::exists() const
83 {
84 return H5Lexists(mParent->id(), mName.c_str(), H5P_DEFAULT) > 0;
85 }
86
87 Dataset& Dataset::init(const RangePtr& dataRange, hid_t type)
88 {
89 CXZ_ASSERT(not isOpen(), "tried to initialize dataset that is already extisting");
92 CXZ_ASSERT(tc != H5T_NO_CLASS, "id does not correspond to a data type"); // (did not found anythng better to check if type id is valid)...
94 // TODO: all sub-ranges explicity!!!:
95 const SizeT ndim = dataRange->dim();
97 for(SizeT i = 0; i != ndim; ++i){
98 exts[i] = static_cast<hsize_t>( dataRange->sub(i)->size() );
99 }
101 mType = type;
102 mId = H5Dcreate(mParent->id(), mName.c_str(), mType, mFilespace,
105 return *this;
106 }
107
109 {
110 return mDataRange;
111 }
112
113 }
114}
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
virtual bool ro() const =0
virtual String path() const =0
const ContentBase * mParent
virtual String filename() const =0
virtual String filename() const override final
Definition h5_dataset.cc:77
virtual Dataset & close() override final
Definition h5_dataset.cc:61
virtual bool exists() const override final
Definition h5_dataset.cc:82
Dataset(const String &name, const ContentBase *_parent)
Definition h5_dataset.cc:18
Dataset & init(const RangePtr &dataRange, hid_t type)
Definition h5_dataset.cc:87
virtual String path() const override final
Definition h5_dataset.cc:72
const RangePtr & dataRange() const
virtual ContentType type() const override final
Definition h5_dataset.cc:31
virtual bool ro() const override final
Definition h5_dataset.cc:36
virtual Dataset & open() override final
Definition h5_dataset.cc:41
Dataset declaration.
std::string String
Definition types.h:42
uint64_t SizeT
Definition types.h:38
RangePtr yrange(const Vector< RangePtr > &rs)
Definition yrange.cc:666
Sptr< RangeBase > RangePtr
Definition types.h:157
std::vector< T, Allocator< T > > Vector
Definition types.h:310
Sptr< Range > rangeCast(const RangePtr r)