Skip to content
Snippets Groups Projects

ENH: Allow insertion and deletion of single entities

Merged Florian Spreckelsen requested to merge f-insert into dev
All threads resolved!
Compare and Show latest version
18 files
+ 180
46
Compare changes
  • Side-by-side
  • Inline
Files
18
+ 34
6
@@ -38,6 +38,12 @@ using caosdb::entity::v1alpha1::IdResponse;
using ProtoParent = caosdb::entity::v1alpha1::Parent;
using ProtoEntity = caosdb::entity::v1alpha1::Entity;
/**
* Messages convey information about the state and result of transactions.
*
* A Message object can be thought of as kinf of a generalized error object in
* other frameworks. Please have a look at MessageCodes for more details.
*/
class Message {
public:
[[nodiscard]] inline auto GetCode() const -> MessageCode {
@@ -48,6 +54,8 @@ public:
}
friend class Entity;
friend class Parent;
friend class Property;
friend class Messages;
private:
@@ -68,6 +76,8 @@ public:
}
friend class Entity;
friend class Parent;
friend class Property;
private:
inline Messages() : wrapped(nullptr){};
@@ -133,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;
@@ -163,6 +185,9 @@ private:
* Message which serves as storage backend.
*/
mutable caosdb::entity::v1alpha1::Parent *wrapped;
Messages errors;
Messages warnings;
Messages infos;
};
/**
@@ -213,8 +238,6 @@ private:
*
* This is a property which belongs to another entity. Don't confuse it with
* an Entity with the "Property" role.
*
* @brief Property of an Entity.
*/
class Property {
public:
@@ -310,6 +333,9 @@ public:
[[nodiscard]] inline auto GetUnit() const -> const std::string & {
return wrapped->unit();
};
[[nodiscard]] inline auto GetValue() const -> const std::string & {
return wrapped->value();
};
[[nodiscard]] auto GetParents() const -> const Parents &;
[[nodiscard]] auto GetProperties() const -> const Properties &;
@@ -322,6 +348,9 @@ public:
[[nodiscard]] auto GetWarnings() const -> const Messages & {
return warnings;
}
[[nodiscard]] inline auto HasWarnings() const -> bool {
return this->warnings.wrapped->size() > 0;
}
[[nodiscard]] auto GetInfos() const -> const Messages & { return infos; }
inline auto ToString() const -> const std::string {
@@ -337,7 +366,6 @@ public:
auto SetName(const std::string &name) -> void;
auto SetVersionId(const std::string &id) -> void;
// TODO(fspreck) ... and also these
auto SetValue(const std::string &value) -> void;
auto SetUnit(const std::string &unit) -> void;
// Currently no references or lists.
Loading