Repository navigation
Remove shared pointer behaviour: take 2 - #20
Open
OliverWoolland wants to merge 3 commits into
Open
OliverWoolland wants to merge 3 commits into
OliverWoolland wants to merge 3 commits into
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So I think this approach to removing the shared pointer oddity might work a bit better ergonomically
I've made the Entity constructor is private and only accessed via the addEntity method of the ROCrate class, which now requires the id at creation.
so for creation
and fetching
This pull request refactors the
Entitylifecycle in the RO-Crate C++ library to ensure that all entities are created and owned by anROCrateinstance via theaddEntitymethod. Direct instantiation ofEntityobjects is now disallowed outside the crate, and all entity manipulations are performed through references returned by the crate. The documentation and tests have been updated to reflect this new pattern, making entity ownership and mutability clearer and safer.Key changes include:
Entity Creation and Ownership Model:
Entityconstructor is now private; entities can only be created viaROCrate::addEntity, which returns a mutable reference to the entity. Direct instantiation (e.g.,Entity({"Person"})) is no longer allowed. (include/ro-crate.hpp, [1] [2]addEntitymethod onROCratenow constructs and registers the entity internally, returning a reference; it no longer accepts an existing entity object as an argument. (include/ro-crate.hpp, [1] [2]API and Internal Data Structure Updates:
shared_ptr, simplifying the property management. (include/ro-crate.hpp, [1] [2]include/ro-crate.hpp, include/ro-crate.hppL376-L386)Documentation and Usage Examples:
README.mdhas been rewritten to explain the new pattern: entities are always created and owned by the crate, and all property updates occur via references returned fromaddEntityorgetEntity. It warns about copying entities (which breaks the reference to the crate). (README.md, [1] [2] [3] [4] [5]Test and Example Refactoring:
tests/example.cpp, [1];tests/integration.cpp, [2]Minor Cleanup:
#include <memory>. (include/ro-crate.hpp, include/ro-crate.hppL6)