Skip to content
Snippets Groups Projects

ENH: Add retrieval and queries to Extern C interface

Merged Florian Spreckelsen requested to merge f-extended-c into f-files
2 unresolved threads
1 file
+ 4
0
Compare changes
  • Side-by-side
  • Inline
+ 10
22
@@ -35,6 +35,8 @@ using ProtoFileDescriptor = caosdb::entity::v1alpha1::FileDescriptor;
using caosdb::utility::get_arena;
using google::protobuf::Arena;
Messages::~Messages() = default;
Parent::Parent() : wrapped(Parent::CreateProtoParent()) {
// TODO(fspreck) Re-enable once we have decided how to attach
// messages to parents.
@@ -51,10 +53,6 @@ auto Parent::SetName(const std::string &name) -> void {
this->wrapped->set_name(name);
}
auto Parent::GetDescription() const -> const std::string & {
return this->wrapped->description();
}
auto Parent::SetId(const std::string &id) -> void { this->wrapped->set_id(id); }
[[nodiscard]] auto Parent::GetId() const -> const std::string & {
@@ -65,15 +63,8 @@ auto Parent::SetId(const std::string &id) -> void { this->wrapped->set_id(id); }
return this->wrapped->name();
}
auto Parents::Append(const Parent &parent) -> void {
auto *destination = this->wrapped->Add();
destination->Swap(parent.wrapped);
// Clear the originally wrapped object and return it to the Arena
parent.wrapped->Clear();
// set the pointer to the new object which is owned by the RepeatedPtrField
parent.wrapped = destination;
[[nodiscard]] auto Parent::GetDescription() const -> const std::string & {
return this->wrapped->description();
}
Property::Property() : wrapped(Property::CreateProtoProperty()) {}
@@ -138,15 +129,6 @@ auto Property::SetDatatype(const std::string &datatype) -> void {
this->wrapped->set_datatype(datatype);
}
auto Properties::Append(const Property &property) -> void {
auto *destination = this->wrapped->Add();
destination->Swap(property.wrapped);
property.wrapped->Clear();
property.wrapped = destination;
}
[[nodiscard]] auto Entity::GetParents() const -> const Parents & {
return parents;
}
@@ -155,6 +137,8 @@ auto Entity::AppendParent(const Parent &parent) -> void {
this->parents.Append(parent);
}
auto Entity::RemoveParent(int index) -> void { this->parents.remove(index); }
[[nodiscard]] auto Entity::GetProperties() const -> const Properties & {
return properties;
}
@@ -163,6 +147,10 @@ auto Entity::AppendProperty(const Property &property) -> void {
this->properties.Append(property);
}
auto Entity::RemoveProperty(int index) -> void {
this->properties.remove(index);
}
auto Entity::CreateProtoEntity() -> ProtoEntity * {
return Arena::CreateMessage<ProtoEntity>(get_arena());
}
Loading