Skip to content
Snippets Groups Projects

F move entity

Merged Timm Fitschen requested to merge f-move-entity into dev
Files
2
+ 61
1
@@ -51,8 +51,8 @@
@@ -51,8 +51,8 @@
#include <random> // for mt19937, rand...
#include <random> // for mt19937, rand...
#include <stdexcept> // for out_of_range
#include <stdexcept> // for out_of_range
#include <string> // for string, basic...
#include <string> // for string, basic...
#include <vector> // for vector
#include <utility> // for move
#include <utility> // for move
 
#include <vector> // for vector
namespace caosdb::entity {
namespace caosdb::entity {
using boost::filesystem::exists;
using boost::filesystem::exists;
@@ -635,6 +635,9 @@ private:
@@ -635,6 +635,9 @@ private:
*/
*/
class Entity : public ScalarProtoMessageWrapper<ProtoEntity> {
class Entity : public ScalarProtoMessageWrapper<ProtoEntity> {
public:
public:
 
/**
 
* Copy constructor.
 
*/
inline Entity(const Entity &original)
inline Entity(const Entity &original)
: Entity(ProtoMessageWrapper::CopyProtoMessage(original.wrapped)) {
: Entity(ProtoMessageWrapper::CopyProtoMessage(original.wrapped)) {
this->errors.wrapped->CopyFrom(*original.errors.wrapped);
this->errors.wrapped->CopyFrom(*original.errors.wrapped);
@@ -671,6 +674,54 @@ public:
@@ -671,6 +674,54 @@ public:
parents.wrapped = this->wrapped->mutable_parents();
parents.wrapped = this->wrapped->mutable_parents();
};
};
 
/**
 
* Move constructor.
 
*/
 
explicit inline Entity(Entity &&original)
 
: wrapped(std::move(original.wrapped)), value(Value(std::move(original.value.wrapped))),
 
data_type(DataType(std::move(original.data_type.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.wrapped = std::move(other.data_type.wrapped);
 
this->value.wrapped = std::move(other.value.wrapped);
 
this->properties.wrapped = std::move(other.properties.wrapped);
 
this->parents.wrapped = std::move(other.parents.wrapped);
 
this->file_descriptor = std::move(other.file_descriptor);
 
this->errors.wrapped = std::move(other.errors.wrapped);
 
this->warnings.wrapped = std::move(other.warnings.wrapped);
 
this->infos.wrapped = std::move(other.infos.wrapped);
 
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 & {
[[nodiscard]] inline auto GetId() const noexcept -> const std::string & {
return this->wrapped->id();
return this->wrapped->id();
};
};
@@ -787,6 +838,15 @@ public:
@@ -787,6 +838,15 @@ public:
infos.Clear();
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:
private:
inline auto GetNextFileId() -> std::string {
inline auto GetNextFileId() -> std::string {
std::string str = "0123456789abcdef";
std::string str = "0123456789abcdef";
Loading