From 3f9227e344093c6210dbf09468b992d0f225ce1c Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Mon, 2 Aug 2021 17:33:46 +0200 Subject: [PATCH] WIP: Add errors, warnings, and infos to Parent --- include/caosdb/entity.h | 25 ++++++++++++++++++++++--- src/caosdb/entity.cpp | 6 +++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index b3eb9e1..8920efe 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -54,6 +54,8 @@ public: } friend class Entity; + friend class Parent; + friend class Property; friend class Messages; private: @@ -74,6 +76,8 @@ public: } friend class Entity; + friend class Parent; + friend class Property; private: inline Messages() : wrapped(nullptr){}; @@ -139,15 +143,27 @@ public: /** * Return the error messages of this parent. */ - [[nodiscard]] inline auto GetErrors() const -> const Messages &; + [[nodiscard]] inline auto GetErrors() const -> const Messages & { + return errors; + } + [[nodiscard]] inline auto HasErrors() const -> bool { + return this->errors.wrapped->size() > 0; + } /** * Return the warning messages of this parent. */ - [[nodiscard]] inline auto GetWarnings() const -> const Messages &; + [[nodiscard]] inline auto GetWarnings() const -> const Messages & { + return warnings; + } + [[nodiscard]] inline auto HasWarnings() const -> bool { + return this->warnings.wrapped->size() > 0; + } /** * Return the info messages of this parent. */ - [[nodiscard]] inline auto GetInfos() const -> const Messages &; + [[nodiscard]] inline auto GetInfos() const -> const Messages & { + return infos; + } friend class Entity; friend class Parents; @@ -169,6 +185,9 @@ private: * Message which serves as storage backend. */ mutable caosdb::entity::v1alpha1::Parent *wrapped; + Messages errors; + Messages warnings; + Messages infos; }; /** diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 8c7359b..84105ed 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -28,7 +28,11 @@ using ProtoParent = caosdb::entity::v1alpha1::Parent; using ProtoEntity = caosdb::entity::v1alpha1::Entity; using caosdb::utility::get_arena; -Parent::Parent() : wrapped(Parent::CreateProtoParent()) {} +Parent::Parent() : wrapped(Parent::CreateProtoParent()) { + errors.wrapped = this->wrapped->mutable_errors(); + warnings.wrapped = this->wrapped->mutable_warnings(); + infos.wrapped = this->wrapped->mutable_infos(); +} auto Parent::CreateProtoParent() -> ProtoParent * { return google::protobuf::Arena::CreateMessage<ProtoParent>(get_arena()); -- GitLab