Skip to content
Snippets Groups Projects

F update

Merged Timm Fitschen requested to merge f-update into dev
4 files
+ 348
48
Compare changes
  • Side-by-side
  • Inline

Files

+ 123
43
@@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
* This file is a part of the CaosDB Project.
* This file is a part of the CaosDB Project.
*
*
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
 
* Copyright (C) 2021 Florian Spreckelsen <f.spreckelsen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
*
*
* This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
@@ -36,6 +37,7 @@
@@ -36,6 +37,7 @@
namespace caosdb::entity {
namespace caosdb::entity {
using caosdb::entity::v1alpha1::IdResponse;
using caosdb::entity::v1alpha1::IdResponse;
using ProtoParent = caosdb::entity::v1alpha1::Parent;
using ProtoParent = caosdb::entity::v1alpha1::Parent;
 
using ProtoProperty = caosdb::entity::v1alpha1::Property;
using ProtoEntity = caosdb::entity::v1alpha1::Entity;
using ProtoEntity = caosdb::entity::v1alpha1::Entity;
/**
/**
@@ -54,8 +56,10 @@ public:
@@ -54,8 +56,10 @@ public:
}
}
friend class Entity;
friend class Entity;
friend class Parent;
// TODO(fspreck) Re-enable once we have decided how messages are
friend class Property;
// appended to parents and properties
 
// friend class Parent;
 
// friend class Property;
friend class Messages;
friend class Messages;
private:
private:
@@ -76,8 +80,9 @@ public:
@@ -76,8 +80,9 @@ public:
}
}
friend class Entity;
friend class Entity;
friend class Parent;
// TODO(fspreck) Same here.
friend class Property;
// friend class Parent;
 
// friend class Property;
private:
private:
inline Messages() : wrapped(nullptr){};
inline Messages() : wrapped(nullptr){};
@@ -134,32 +139,32 @@ public:
@@ -134,32 +139,32 @@ public:
return out;
return out;
}
}
// TODO(fspreck) These need implementations. See Entity::GetErrors for
// TODO(fspreck) Finish the following implementations once we have
// inspiration.
// decided how to attach messages to parents.
/**
// /**
* Return the error messages of this parent.
// * Return the error messages of this parent.
*/
// */
[[nodiscard]] inline auto GetErrors() const -> const Messages & {
// [[nodiscard]] inline auto GetErrors() const -> const Messages & {
return errors;
// return errors;
}
// }
[[nodiscard]] inline auto HasErrors() const -> bool {
// [[nodiscard]] inline auto HasErrors() const -> bool {
return this->errors.wrapped->size() > 0;
// return this->errors.wrapped->size() > 0;
}
// }
/**
// /**
* Return the warning messages of this parent.
// * Return the warning messages of this parent.
*/
// */
[[nodiscard]] inline auto GetWarnings() const -> const Messages & {
// [[nodiscard]] inline auto GetWarnings() const -> const Messages & {
return warnings;
// return warnings;
}
// }
[[nodiscard]] inline auto HasWarnings() const -> bool {
// [[nodiscard]] inline auto HasWarnings() const -> bool {
return this->warnings.wrapped->size() > 0;
// return this->warnings.wrapped->size() > 0;
}
// }
/**
// /**
* Return the info messages of this parent.
// * Return the info messages of this parent.
*/
// */
[[nodiscard]] inline auto GetInfos() const -> const Messages & {
// [[nodiscard]] inline auto GetInfos() const -> const Messages & {
return infos;
// return infos;
}
// }
friend class Entity;
friend class Entity;
friend class Parents;
friend class Parents;
@@ -181,9 +186,9 @@ private:
@@ -181,9 +186,9 @@ private:
* Message which serves as storage backend.
* Message which serves as storage backend.
*/
*/
mutable caosdb::entity::v1alpha1::Parent *wrapped;
mutable caosdb::entity::v1alpha1::Parent *wrapped;
Messages errors;
// Messages errors;
Messages warnings;
// Messages warnings;
Messages infos;
// Messages infos;
};
};
/**
/**
@@ -239,31 +244,88 @@ class Property {
@@ -239,31 +244,88 @@ class Property {
public:
public:
explicit inline Property(caosdb::entity::v1alpha1::Property *wrapped)
explicit inline Property(caosdb::entity::v1alpha1::Property *wrapped)
: wrapped(wrapped){};
: wrapped(wrapped){};
 
Property();
// TODO(fspreck) All of these methods need implementations.
/**
 
* Return the id of this property
 
*/
[[nodiscard]] auto GetId() const -> const std::string &;
[[nodiscard]] auto GetId() const -> const std::string &;
 
/**
 
* Return the name of this property
 
*/
[[nodiscard]] auto GetName() const -> const std::string &;
[[nodiscard]] auto GetName() const -> const std::string &;
 
/**
 
* Return the description of this property
 
*/
[[nodiscard]] auto GetDescription() const -> const std::string &;
[[nodiscard]] auto GetDescription() const -> const std::string &;
 
/**
 
* Return the importance of this property
 
*/
[[nodiscard]] auto GetImportance() const -> const std::string &;
[[nodiscard]] auto GetImportance() const -> const std::string &;
 
/**
 
* Return the value of this property
 
*/
[[nodiscard]] auto GetValue() const -> const std::string &;
[[nodiscard]] auto GetValue() const -> const std::string &;
 
/**
 
* Return the unit of this property
 
*/
[[nodiscard]] auto GetUnit() const -> const std::string &;
[[nodiscard]] auto GetUnit() const -> const std::string &;
 
/**
 
* Return the datatype of this property
 
*/
[[nodiscard]] auto GetDatatype() const -> const std::string &;
[[nodiscard]] auto GetDatatype() const -> const std::string &;
[[nodiscard]] auto GetErrors() const -> const Messages &;
// TODO(fspreck) Implement these when we have decided how to attach
[[nodiscard]] auto GetWarnings() const -> const Messages &;
// messages to properties.
[[nodiscard]] auto GetInfos() const -> const Messages &;
// [[nodiscard]] auto GetErrors() const -> const Messages &;
 
// [[nodiscard]] auto GetWarnings() const -> const Messages &;
 
// [[nodiscard]] auto GetInfos() const -> const Messages &;
 
/**
 
* Set the id of this property.
 
*/
auto SetId(const std::string &id) -> void;
auto SetId(const std::string &id) -> void;
 
/**
 
* Set the name of this property.
 
*/
auto SetName(const std::string &name) -> void;
auto SetName(const std::string &name) -> void;
 
/**
 
* Set the importance of this property.
 
*/
auto SetImportance(const std::string &importance) -> void;
auto SetImportance(const std::string &importance) -> void;
 
/**
 
* Set the value of this property.
 
*/
auto SetValue(const std::string &value) -> void;
auto SetValue(const std::string &value) -> void;
 
/**
 
* Set the unit of this property.
 
*/
auto SetUnit(const std::string &unit) -> void;
auto SetUnit(const std::string &unit) -> void;
 
/**
 
* Set the datatype of this property.
 
*/
auto SetDatatype(const std::string &datatype) -> void;
auto SetDatatype(const std::string &datatype) -> void;
 
/**
 
* Return a json string representing this property.
 
*
 
* This is intended for debugging
 
*/
 
inline auto ToString() const -> const std::string {
 
google::protobuf::util::JsonOptions options;
 
std::string out;
 
google::protobuf::util::MessageToJsonString(*(this->wrapped), &out,
 
options);
 
 
return out;
 
}
 
friend class Entity;
friend class Entity;
friend class Properties;
friend class Properties;
private:
private:
caosdb::entity::v1alpha1::Property *wrapped;
static auto CreateProtoProperty() -> ProtoProperty *;
 
 
mutable caosdb::entity::v1alpha1::Property *wrapped;
};
};
/**
/**
@@ -273,10 +335,18 @@ private:
@@ -273,10 +335,18 @@ private:
*/
*/
class Properties {
class Properties {
public:
public:
// TODO(fspreck) Implementations needed (basically everything). See Parents
/**
// container for inspiration.
* Return the current size of the properties container.
[[nodiscard]] auto At(int index) const -> const Property &;
*
auto Append(const Property &property) -> void;
* This is also the number of properties the owningn entity currently has.
 
*/
 
[[nodiscard]] inline auto Size() const -> int { return wrapped->size(); }
 
/**
 
* Return the property at the given index.
 
*/
 
[[nodiscard]] auto At(int index) const -> const Property {
 
return Property(&(wrapped->at(index)));
 
}
friend class Entity;
friend class Entity;
@@ -287,6 +357,13 @@ private:
@@ -287,6 +357,13 @@ private:
*wrapped)
*wrapped)
: wrapped(wrapped){};
: wrapped(wrapped){};
 
/**
 
* Append a property
 
*
 
* This increases the Size() by one.
 
*/
 
auto Append(const Property &property) -> void;
 
::google::protobuf::RepeatedPtrField<caosdb::entity::v1alpha1::Property>
::google::protobuf::RepeatedPtrField<caosdb::entity::v1alpha1::Property>
*wrapped;
*wrapped;
};
};
@@ -370,11 +447,14 @@ public:
@@ -370,11 +447,14 @@ public:
auto SetUnit(const std::string &unit) -> void;
auto SetUnit(const std::string &unit) -> void;
// Currently no references or lists.
// Currently no references or lists.
auto SetDatatype(const std::string &datatype) -> void;
auto SetDatatype(const std::string &datatype) -> void;
// TODO(fspreck) this one is tricky. See AppendParent
auto AppendProperty(const Property &property) -> void;
auto AppendProperty(const Property &property) -> void;
auto AppendParent(const Parent &parent) -> void;
auto AppendParent(const Parent &parent) -> void;
auto Switch(ProtoEntity *entity) -> void;
auto Switch(ProtoEntity *entity) -> void;
 
/**
 
* Copy all of this entity's features to the target ProtoEntity.
 
*/
 
auto CopyTo(ProtoEntity *target) -> void;
protected:
protected:
static auto CreateProtoEntity() -> ProtoEntity *;
static auto CreateProtoEntity() -> ProtoEntity *;
Loading