Skip to content

Document ownership relation between layer and feature #36

@anandthakker

Description

@anandthakker

It looks to me like vtzero::feature depends on having a pointer to its vtzero::layer object (specifically for getting property data):

inline property feature::next_property() {
const auto idxs = next_property_indexes();
property p{};
if (idxs.valid()) {
p = {m_layer->key(idxs.key()),
m_layer->value(idxs.value())};
}
return p;
}

However, this requirement isn’t enforced--it's possible, for instance, to do:

vtzero::feature getFeature(vtzero::tile tile, std::string layer, uint64_t id) {
  return tile.get_layer_by_name(layer).get_feature_by_id(id);
}

and end up with a feature whose owning layer has been destroyed.

Since presumably the overhead of enforcing this with a shared_ptr would be undesirable, would it make sense to at least make a note of this in the documentation for feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions