Skip to content
Snippets Groups Projects

F move entity

Merged Timm Fitschen requested to merge f-move-entity into dev
Files
2
+ 59
1
@@ -51,8 +51,8 @@
#include <random> // for mt19937, rand...
#include <stdexcept> // for out_of_range
#include <string> // for string, basic...
#include <vector> // for vector
#include <utility> // for move
#include <vector> // for vector
namespace caosdb::entity {
using boost::filesystem::exists;
@@ -635,6 +635,9 @@ private:
*/
class Entity : public ScalarProtoMessageWrapper<ProtoEntity> {
public:
/**
* Copy constructor.
*/
inline Entity(const Entity &original)
: Entity(ProtoMessageWrapper::CopyProtoMessage(original.wrapped)) {
this->errors.wrapped->CopyFrom(*original.errors.wrapped);
@@ -671,6 +674,52 @@ public:
parents.wrapped = this->wrapped->mutable_parents();
};
/**
* Move constructor.
*/
explicit inline Entity(Entity &&original) : Entity(std::move(original.wrapped)) {
this->properties.wrapped = std::move(original.properties.wrapped);
this->parents.wrapped = std::move(original.parents.wrapped);
this->errors.wrapped = std::move(original.errors.wrapped);
this->warnings.wrapped = std::move(original.warnings.wrapped);
this->infos.wrapped = std::move(original.infos.wrapped);
};
/**
* Move assignment operator.
*/
auto operator=(Entity &&other) -> Entity & {
this->wrapped = std::move(other.wrapped);
this->data_type = std::move(other.data_type);
this->value = std::move(other.value);
this->properties = std::move(other.properties);
this->parents = std::move(other.parents);
this->file_descriptor = std::move(other.file_descriptor);
this->errors = std::move(other.errors);
this->warnings = std::move(other.warnings);
this->infos = std::move(other.infos);
return *this;
}
/**
* Copy assignment operator.
*/
auto operator=(const Entity &other) -> Entity & {
this->wrapped->CopyFrom(*other.wrapped);
this->data_type.wrapped->CopyFrom(*other.data_type.wrapped);
this->value.wrapped->CopyFrom(*other.value.wrapped);
this->properties.wrapped->CopyFrom(*other.properties.wrapped);
this->parents.wrapped->CopyFrom(*other.parents.wrapped);
this->file_descriptor.local_path = boost::filesystem::path(other.file_descriptor.local_path);
this->file_descriptor.file_transmission_id->CopyFrom(
*other.file_descriptor.file_transmission_id);
this->file_descriptor.wrapped->CopyFrom(*other.file_descriptor.wrapped);
this->errors.wrapped->CopyFrom(*other.errors.wrapped);
this->warnings.wrapped->CopyFrom(*other.warnings.wrapped);
this->infos.wrapped->CopyFrom(*other.infos.wrapped);
return *this;
}
[[nodiscard]] inline auto GetId() const noexcept -> const std::string & {
return this->wrapped->id();
};
@@ -787,6 +836,15 @@ public:
infos.Clear();
}
/**
* Return true if the other entity is equal to to this entity.
*
* This method ignores the errors, warnings and info messages.
*/
inline auto operator==(const Entity &other) const noexcept -> bool {
return this->wrapped->SerializeAsString() == other.wrapped->SerializeAsString();
}
private:
inline auto GetNextFileId() -> std::string {
std::string str = "0123456789abcdef";
Loading