Skip to content
Snippets Groups Projects
Verified Commit ac18a98e authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: consolidation

parent 33b57593
No related branches found
No related tags found
1 merge request!12F consolidation
......@@ -453,9 +453,9 @@ private:
*/
class Property {
public:
explicit inline Property(ProtoProperty *wrapped)
: wrapped(wrapped), data_type(DataType(wrapped->mutable_data_type())),
value(Value(wrapped->mutable_value())){};
explicit inline Property(ProtoProperty *other)
: value(Value(other->mutable_value())),
data_type(DataType(other->mutable_data_type())), wrapped(other){};
Property();
/**
......@@ -581,9 +581,9 @@ class Entity {
public:
Entity();
inline Entity(const Entity &original)
: wrapped(CreateProtoEntity()),
data_type(DataType(wrapped->mutable_data_type())),
value(Value(wrapped->mutable_value())) {
: wrapped(original.wrapped),
value(Value(original.wrapped->mutable_value())),
data_type(DataType(original.wrapped->mutable_data_type())) {
this->wrapped->CopyFrom(*original.wrapped);
data_type.wrapped = this->wrapped->mutable_data_type();
value.wrapped = this->wrapped->mutable_value();
......@@ -594,9 +594,9 @@ public:
infos.wrapped = CreateMessagesField();
};
explicit Entity(IdResponse *id_response);
explicit Entity(ProtoEntity *wrapped)
: wrapped(wrapped), data_type(DataType(wrapped->mutable_data_type())),
value(Value(wrapped->mutable_value())) {
explicit Entity(ProtoEntity *other)
: wrapped(other), value(Value(other->mutable_value())),
data_type(DataType(other->mutable_data_type())) {
data_type.wrapped = this->wrapped->mutable_data_type();
value.wrapped = this->wrapped->mutable_value();
properties.wrapped = this->wrapped->mutable_properties();
......
......@@ -41,6 +41,7 @@ auto get_arena() -> Arena *;
template <typename P> class ProtoMessageWrapper {
public:
ProtoMessageWrapper(const ProtoMessageWrapper &other) = default;
inline auto CopyFrom(const ProtoMessageWrapper &other) noexcept
-> StatusCode {
this->wrapped->CopyFrom(*other.wrapped);
......
......@@ -102,13 +102,11 @@ public:
class Value : public ProtoMessageWrapper<ProtoValue> {
public:
explicit inline Value(const Value &value){
this->wrapped = value.wrapped;
}
inline Value() : ProtoMessageWrapper<ProtoValue>() {
// has NULL_VALUE now
}
explicit inline Value(ProtoValue *wrapped) : ProtoMessageWrapper<ProtoValue>(wrapped) {}
explicit inline Value(ProtoValue *wrapped)
: ProtoMessageWrapper<ProtoValue>(wrapped) {}
explicit inline Value(const std::string &value)
: ProtoMessageWrapper<ProtoValue>() {
this->wrapped->mutable_scalar_value()->set_string_value(value);
......
......@@ -105,7 +105,7 @@ TEST(test_protobuf, test_copy_nested) {
Entity entity(&entity_destination);
EXPECT_EQ(entity.GetDataType().AsReference().GetName(), "src_per");
Entity copy_entity(entity);
const Entity &copy_entity(entity);
EXPECT_EQ(copy_entity.GetDataType().AsReference().GetName(), "src_per");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment