|
@@ -7,7 +7,7 @@
|
|
#include <hdf/mfhdf.h>
|
|
#include <hdf/mfhdf.h>
|
|
#include <sstream>
|
|
#include <sstream>
|
|
|
|
|
|
-hdf4cpp::HdfDatasetItem::HdfDatasetItem(int32 id) : HdfItemBase(id, SDATA) {
|
|
+hdf4cpp::HdfDatasetItem::HdfDatasetItem(int32 id, const HdfDestroyerChain& chain) : HdfItemBase(id, SDATA, chain) {
|
|
_size = 1;
|
|
_size = 1;
|
|
std::for_each(dims.begin(), dims.end(), [this](const int32 &t) {
|
|
std::for_each(dims.begin(), dims.end(), [this](const int32 &t) {
|
|
_size *= t;
|
|
_size *= t;
|
|
@@ -18,12 +18,13 @@ hdf4cpp::HdfDatasetItem::HdfDatasetItem(int32 id) : HdfItemBase(id, SDATA) {
|
|
SDgetinfo(id, _name, &size, dim, &dataType, nullptr);
|
|
SDgetinfo(id, _name, &size, dim, &dataType, nullptr);
|
|
dims = std::vector<int32>(dim, dim + size);
|
|
dims = std::vector<int32>(dim, dim + size);
|
|
name = std::string(_name);
|
|
name = std::string(_name);
|
|
|
|
+ this->chain.push_back(new HdfDatasetItemDestroyer(id));
|
|
}
|
|
}
|
|
std::vector<int32> hdf4cpp::HdfDatasetItem::getDims() {
|
|
std::vector<int32> hdf4cpp::HdfDatasetItem::getDims() {
|
|
return dims;
|
|
return dims;
|
|
}
|
|
}
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfDatasetItem::getAttribute(const std::string &name) const {
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfDatasetItem::getAttribute(const std::string &name) const {
|
|
- return HdfAttribute(new HdfDatasetAttribute(id, name));
|
|
+ return HdfAttribute(new HdfDatasetAttribute(id, name, chain));
|
|
}
|
|
}
|
|
std::string hdf4cpp::HdfDatasetItem::getName() const {
|
|
std::string hdf4cpp::HdfDatasetItem::getName() const {
|
|
return name;
|
|
return name;
|
|
@@ -35,21 +36,21 @@ int32 hdf4cpp::HdfDatasetItem::getDataType() const {
|
|
return dataType;
|
|
return dataType;
|
|
}
|
|
}
|
|
hdf4cpp::HdfDatasetItem::~HdfDatasetItem() {
|
|
hdf4cpp::HdfDatasetItem::~HdfDatasetItem() {
|
|
- SDendaccess(id);
|
|
|
|
}
|
|
}
|
|
intn hdf4cpp::HdfDatasetItem::size() const {
|
|
intn hdf4cpp::HdfDatasetItem::size() const {
|
|
return _size;
|
|
return _size;
|
|
}
|
|
}
|
|
-hdf4cpp::HdfGroupItem::HdfGroupItem(int32 id) : HdfItemBase(id, VGROUP) {
|
|
+hdf4cpp::HdfGroupItem::HdfGroupItem(int32 id, const HdfDestroyerChain& chain) : HdfItemBase(id, VGROUP, chain) {
|
|
char _name[MAX_NAME_LENGTH];
|
|
char _name[MAX_NAME_LENGTH];
|
|
Vgetname(id, _name);
|
|
Vgetname(id, _name);
|
|
name = std::string(_name);
|
|
name = std::string(_name);
|
|
|
|
+ this->chain.push_back(new HdfGroupItemDestroyer(id));
|
|
}
|
|
}
|
|
std::vector<int32> hdf4cpp::HdfGroupItem::getDims() {
|
|
std::vector<int32> hdf4cpp::HdfGroupItem::getDims() {
|
|
raiseException(INVALID_OPERATION);
|
|
raiseException(INVALID_OPERATION);
|
|
}
|
|
}
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfGroupItem::getAttribute(const std::string &name) const {
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfGroupItem::getAttribute(const std::string &name) const {
|
|
- return HdfAttribute(new HdfGroupAttribute(id, name));
|
|
+ return HdfAttribute(new HdfGroupAttribute(id, name, chain));
|
|
}
|
|
}
|
|
std::string hdf4cpp::HdfGroupItem::getName() const {
|
|
std::string hdf4cpp::HdfGroupItem::getName() const {
|
|
return name;
|
|
return name;
|
|
@@ -58,7 +59,6 @@ int32 hdf4cpp::HdfGroupItem::getId() const {
|
|
return id;
|
|
return id;
|
|
}
|
|
}
|
|
hdf4cpp::HdfGroupItem::~HdfGroupItem() {
|
|
hdf4cpp::HdfGroupItem::~HdfGroupItem() {
|
|
- Vdetach(id);
|
|
|
|
}
|
|
}
|
|
intn hdf4cpp::HdfGroupItem::size() const {
|
|
intn hdf4cpp::HdfGroupItem::size() const {
|
|
raiseException(INVALID_OPERATION);
|
|
raiseException(INVALID_OPERATION);
|
|
@@ -66,7 +66,7 @@ intn hdf4cpp::HdfGroupItem::size() const {
|
|
int32 hdf4cpp::HdfGroupItem::getDataType() const {
|
|
int32 hdf4cpp::HdfGroupItem::getDataType() const {
|
|
raiseException(INVALID_OPERATION);
|
|
raiseException(INVALID_OPERATION);
|
|
}
|
|
}
|
|
-hdf4cpp::HdfDataItem::HdfDataItem(int32 id) : HdfItemBase(id, VDATA) {
|
|
+hdf4cpp::HdfDataItem::HdfDataItem(int32 id, const HdfDestroyerChain& chain) : HdfItemBase(id, VDATA, chain) {
|
|
char fieldNameList[MAX_NAME_LENGTH];
|
|
char fieldNameList[MAX_NAME_LENGTH];
|
|
char _name[MAX_NAME_LENGTH];
|
|
char _name[MAX_NAME_LENGTH];
|
|
VSinquire(id, &nrRecords, &interlace, fieldNameList, &recordSize, _name);
|
|
VSinquire(id, &nrRecords, &interlace, fieldNameList, &recordSize, _name);
|
|
@@ -76,12 +76,12 @@ hdf4cpp::HdfDataItem::HdfDataItem(int32 id) : HdfItemBase(id, VDATA) {
|
|
while(getline(in, token, ',')) {
|
|
while(getline(in, token, ',')) {
|
|
fieldNames.push_back(token);
|
|
fieldNames.push_back(token);
|
|
}
|
|
}
|
|
|
|
+ this->chain.push_back(new HdfDataItemDestroyer(id));
|
|
}
|
|
}
|
|
hdf4cpp::HdfDataItem::~HdfDataItem() {
|
|
hdf4cpp::HdfDataItem::~HdfDataItem() {
|
|
- VSdetach(id);
|
|
|
|
}
|
|
}
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfDataItem::getAttribute(const std::string &name) const {
|
|
hdf4cpp::HdfAttribute hdf4cpp::HdfDataItem::getAttribute(const std::string &name) const {
|
|
- return HdfAttribute(new HdfDataAttribute(id, name));
|
|
+ return HdfAttribute(new HdfDataAttribute(id, name, chain));
|
|
}
|
|
}
|
|
int32 hdf4cpp::HdfDataItem::getId() const {
|
|
int32 hdf4cpp::HdfDataItem::getId() const {
|
|
return id;
|
|
return id;
|
|
@@ -102,10 +102,10 @@ int32 hdf4cpp::HdfDataItem::getDataType() const {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
hdf4cpp::HdfItem::HdfItem(HdfItemBase *item, int32 sId, int32 vId) : HdfObject(item),
|
|
hdf4cpp::HdfItem::HdfItem(HdfItemBase *item, int32 sId, int32 vId) : HdfObject(item),
|
|
- item(item),
|
|
+ item(item),
|
|
- sId(sId),
|
|
+ sId(sId),
|
|
- vId(vId) {}
|
|
+ vId(vId) {}
|
|
-hdf4cpp::HdfItem::HdfItem(HdfItem&& other) : HdfObject(other.getType(), other.getClassType()),
|
|
+hdf4cpp::HdfItem::HdfItem(HdfItem&& other) : HdfObject(other.getType(), other.getClassType(), std::move(other.chain)),
|
|
item(std::move(other.item)),
|
|
item(std::move(other.item)),
|
|
sId(other.sId),
|
|
sId(other.sId),
|
|
vId(other.vId) {}
|
|
vId(other.vId) {}
|
|
@@ -129,16 +129,16 @@ intn hdf4cpp::HdfItem::size() const {
|
|
return item->size();
|
|
return item->size();
|
|
}
|
|
}
|
|
hdf4cpp::HdfItem::Iterator hdf4cpp::HdfItem::begin() const {
|
|
hdf4cpp::HdfItem::Iterator hdf4cpp::HdfItem::begin() const {
|
|
- return Iterator(sId, vId, item->getId(), 0, getType());
|
|
+ return Iterator(sId, vId, item->getId(), 0, getType(), chain);
|
|
}
|
|
}
|
|
hdf4cpp::HdfItem::Iterator hdf4cpp::HdfItem::end() const {
|
|
hdf4cpp::HdfItem::Iterator hdf4cpp::HdfItem::end() const {
|
|
switch(item->getType()) {
|
|
switch(item->getType()) {
|
|
case VGROUP: {
|
|
case VGROUP: {
|
|
int32 size = Vntagrefs(item->getId());
|
|
int32 size = Vntagrefs(item->getId());
|
|
- return Iterator(sId, vId, item->getId(), size, getType());
|
|
+ return Iterator(sId, vId, item->getId(), size, getType(), chain);
|
|
}
|
|
}
|
|
default: {
|
|
default: {
|
|
- return Iterator(sId, vId, item->getId(), 0, getType());
|
|
+ return Iterator(sId, vId, item->getId(), 0, getType(), chain);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|