From ed3d916ab0ef44a62d391015b99be2666e7983b0 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 12 Aug 2021 12:57:14 +0200 Subject: [PATCH] WIP: Value, DataType, Importance --- include/caosdb/entity.h | 18 +++++++++++++++--- proto | 2 +- src/caosdb/entity.cpp | 13 +++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index 37a1797..bbccf11 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -40,6 +40,18 @@ using ProtoParent = caosdb::entity::v1alpha1::Parent; using ProtoProperty = caosdb::entity::v1alpha1::Property; using ProtoEntity = caosdb::entity::v1alpha1::Entity; using ProtoMessage = caosdb::entity::v1alpha1::Message; +using caosdb::entity::v1alpha1::EntityRole; + +/** + * The entity role. + */ +enum Role { + NONE = EntityRole::ENTITY_ROLE_UNSPECIFIED, ///< Unset/None + RECORD_TYPE = EntityRole::ENTITY_ROLE_RECORD_TYPE, ///< RecordType + RECORD = EntityRole::ENTITY_ROLE_RECORD, ///< Record + PROPERTY = EntityRole::ENTITY_ROLE_PROPERTY, ///< Property + FILE = EntityRole::ENTITY_ROLE_FILE, ///< File +}; /** * Messages convey information about the state and result of transactions. @@ -374,7 +386,7 @@ public: inline Entity(const Entity &original) : Entity(CreateProtoEntity()) { this->wrapped->CopyFrom(*original.wrapped); }; - explicit Entity(IdResponse *idResponse); + explicit Entity(IdResponse *id_response); explicit inline Entity(ProtoEntity *wrapped) : wrapped(wrapped) { errors.wrapped = this->wrapped->mutable_errors(); warnings.wrapped = this->wrapped->mutable_warnings(); @@ -393,7 +405,7 @@ public: return wrapped->version().id(); }; - [[nodiscard]] inline auto GetRole() const -> const std::string & { + [[nodiscard]] inline auto GetRole() const -> Role & { return wrapped->role(); }; [[nodiscard]] inline auto GetName() const -> const std::string & { @@ -437,7 +449,7 @@ public: return out; } - auto SetRole(const std::string &role) -> void; + auto SetRole(Role role) -> void; auto SetName(const std::string &name) -> void; /** * Set the description of this entity. diff --git a/proto b/proto index 36d7956..4ce7460 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 36d7956b6eca506fb87096d8d50b6f4b820778b8 +Subproject commit 4ce7460ff869422c419623c8d0cee0459ce6d6dc diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 03a234b..67eade2 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -171,12 +171,13 @@ Entity::Entity() : wrapped(Entity::CreateProtoEntity()) { infos.wrapped = this->wrapped->mutable_infos(); } -Entity::Entity(IdResponse *idResponse) : Entity() { - this->wrapped->set_id(idResponse->id()); - this->wrapped->mutable_errors()->Swap(idResponse->mutable_entity_errors()); +Entity::Entity(IdResponse *id_response) : Entity() { + this->wrapped->set_id(id_response->id()); + this->wrapped->mutable_version()->Swap(id_response->mutable_version()); + this->wrapped->mutable_errors()->Swap(id_response->mutable_entity_errors()); this->wrapped->mutable_warnings()->Swap( - idResponse->mutable_entity_warnings()); - this->wrapped->mutable_infos()->Swap(idResponse->mutable_entity_infos()); + id_response->mutable_entity_warnings()); + this->wrapped->mutable_infos()->Swap(id_response->mutable_entity_infos()); } auto Entity::SetId(const std::string &id) -> void { this->wrapped->set_id(id); } @@ -189,7 +190,7 @@ auto Entity::CopyTo(ProtoEntity *target) -> void { target->CopyFrom(*(this->wrapped)); } -auto Entity::SetRole(const std::string &role) -> void { +auto Entity::SetRole(Role role) -> void { this->wrapped->set_role(role); } -- GitLab