Exemplo n.º 1
0
bool BaseTagHDF5::hasReference(const std::string &name_or_id) const {
    std::string id = name_or_id;

    if (!util::looksLikeUUID(name_or_id) && block()->hasDataArray(name_or_id)) {
        id = block()->getDataArray(name_or_id)->id();
    }

    return refs_group() ? refs_group()->hasGroup(id) : false;
}
Exemplo n.º 2
0
void BaseTagHDF5::addReference(const std::string &name_or_id) {
    boost::optional<Group> g = refs_group(true);

    if (!block()->hasDataArray(name_or_id))
        throw std::runtime_error("BaseTagHDF5::addReference: DataArray not found in block!");

    auto target = dynamic_pointer_cast<DataArrayHDF5>(block()->getDataArray(name_or_id));

    g->createLink(target->group(), target->id());
}
Exemplo n.º 3
0
std::shared_ptr<IDataArray>  BaseTagHDF5::getReference(const std::string &name_or_id) const {
    std::shared_ptr<IDataArray> da;
    boost::optional<H5Group> g = refs_group(false);

    std::string id = block()->resolveEntityId({name_or_id, ObjectType::DataArray});
    if (g && hasReference(id)) {
        H5Group group = g->openGroup(id);
        da = std::make_shared<DataArrayHDF5>(file(), block(), group);
    }

    return da;
}
Exemplo n.º 4
0
bool BaseTagHDF5::removeReference(const std::string &name_or_id) {
    boost::optional<Group> g = refs_group();
    bool removed = false;

    if (g && hasReference(name_or_id)) {
        shared_ptr<IDataArray> reference = getReference(name_or_id);

        g->removeGroup(reference->id());
        removed = true;
    }

    return removed;
}
Exemplo n.º 5
0
shared_ptr<IDataArray>  BaseTagHDF5::getReference(const std::string &name_or_id) const {
    shared_ptr<IDataArray> da;
    boost::optional<Group> g = refs_group();

    std::string id = name_or_id;

    if (!util::looksLikeUUID(name_or_id) && block()->hasDataArray(name_or_id)) {
        id = block()->getDataArray(name_or_id)->id();
    }

    if (g && hasReference(id)) {
        Group group = g->openGroup(id);
        da = make_shared<DataArrayHDF5>(file(), block(), group);
    }

    return da;
}
Exemplo n.º 6
0
shared_ptr<IDataArray>  BaseTagHDF5::getReference(size_t index) const {
    boost::optional<Group> g = refs_group();
    string id = g ? g->objectName(index) : "";
    return getReference(id);
}
Exemplo n.º 7
0
ndsize_t BaseTagHDF5::referenceCount() const {
    boost::optional<Group> g = refs_group();
    return g ? g->objectCount() : size_t(0);
}
Exemplo n.º 8
0
bool BaseTagHDF5::hasReference(const std::string &name_or_id) const {
    std::string id = block()->resolveEntityId({name_or_id, ObjectType::DataArray});
    return refs_group(false) ? refs_group(false)->hasGroup(id) : false;
}