Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 108-implement-rpc-call-for-server-side-scripting
  • dev
  • f-consol-message
  • f-rel-path
  • f-related-projects
  • f-remote-path
  • f-role
  • f-sss4grpc
  • f-to-string
  • f-update-requirements
  • f-windows-conan-create
  • main
  • v0.0.1
  • v0.0.10
  • v0.0.15
  • v0.0.16
  • v0.0.18
  • v0.0.19
  • v0.0.2
  • v0.0.3
  • v0.0.4
  • v0.0.5
  • v0.0.6
  • v0.0.7
  • v0.0.8
  • v0.0.9
  • v0.1
  • v0.1.1
  • v0.1.2
  • v0.2.0
  • v0.2.1
  • v0.2.2
  • v0.3.0
33 results

Target

Select target project
  • caosdb/src/caosdb-cpplib
1 result
Select Git revision
  • 108-implement-rpc-call-for-server-side-scripting
  • dev
  • f-consol-message
  • f-rel-path
  • f-related-projects
  • f-remote-path
  • f-role
  • f-sss4grpc
  • f-to-string
  • f-update-requirements
  • f-windows-conan-create
  • main
  • v0.0.1
  • v0.0.10
  • v0.0.15
  • v0.0.16
  • v0.0.18
  • v0.0.19
  • v0.0.2
  • v0.0.3
  • v0.0.4
  • v0.0.5
  • v0.0.6
  • v0.0.7
  • v0.0.8
  • v0.0.9
  • v0.1
  • v0.1.1
  • v0.1.2
  • v0.2.0
  • v0.2.1
  • v0.2.2
  • v0.3.0
33 results
Show changes
Commits on Source (5)
......@@ -181,6 +181,8 @@ public:
}
}
~DataType() = default;
inline static auto ListOf(const AtomicDataType &atomic_data_type) -> DataType {
return DataType(atomic_data_type, true);
}
......
......@@ -383,6 +383,37 @@ class Parent : public ScalarProtoMessageWrapper<ProtoParent> {
public:
explicit inline Parent(ProtoParent *wrapped) : ScalarProtoMessageWrapper<ProtoParent>(wrapped){};
Parent() : ScalarProtoMessageWrapper<ProtoParent>(){};
~Parent() = default;
/**
* Copy constructor.
*/
inline Parent(const Parent &other)
: Parent(ProtoMessageWrapper<ProtoParent>::CopyProtoMessage(other.wrapped)) {}
/**
* Move constructor.
*/
inline Parent(Parent &&other) : Parent(other.wrapped) { other.wrapped = nullptr; }
/**
* Copy assignment operator.
*/
inline auto operator=(const Parent &other) -> Parent & {
if (this != &other) {
this->wrapped->CopyFrom(*other.wrapped);
}
return *this;
}
/**
* Move assignment operator.
*/
inline auto operator=(Parent &&other) -> Parent & {
this->wrapped = other.wrapped;
other.wrapped = nullptr;
return *this;
}
/**
* Return the id of the parent entity.
......@@ -497,6 +528,8 @@ public:
: ScalarProtoMessageWrapper<ProtoProperty>(), value(static_cast<ProtoValue *>(nullptr)),
data_type(static_cast<ProtoDataType *>(nullptr)){};
~Property() = default;
/**
* Return the id of this property
*/
......@@ -648,14 +681,17 @@ private:
* Overview of the Constructors:
*
* <li> Entity() - Calls Entity(ProtoEntity *) with a fresh ProtoEntity
* <li> Entity(Entity) - Copy constructor, calls Entity(ProtoEntity *) after copying wrapped
* ProtoEntity of the original, then also copies all Messages. <li> Entity(ProtoEntity *) - The
* workhorse of the constructors. Initializes everything and does not call other Entity
* constructors. <li> Entity(EntityResponse *) - Constructor which is used by the Transaction class
* to create an Entity from the server's response, calls Entity(ProtoEntity). <li> Entity(IdResponse
* *) - Constructor which is used by the Transaction class to create an Entity from the servers's
* response. calls Entity(), then moves the data to the wrapped ProtoEntity.
*
* <li> Entity(const Entity&) - Copy constructor, calls Entity(ProtoEntity *) after
* copying wrapped ProtoEntity of the original, then also copies all Messages.
* <li> Entity(ProtoEntity *) - The workhorse of the constructors. Initializes
* everything and does not call other Entity constructors.
* <li> Entity(EntityResponse *) - Constructor which is used by the Transaction class
* to create an Entity from the server's response, calls Entity(ProtoEntity).
* <li> Entity(IdResponse *) - Constructor which is used by the Transaction
* class to create an Entity from the servers's response. calls Entity(),
* then moves the data to the wrapped ProtoEntity.
* <li> Entity(Entity&&) - Move constructor, calls Entity(ProtoEntity *), then
* moves the messages and resets the original,
*/
class Entity : public ScalarProtoMessageWrapper<ProtoEntity> {
public:
......@@ -698,6 +734,8 @@ public:
parents.wrapped = this->wrapped->mutable_parents();
};
~Entity() = default;
/**
* Move constructor.
*/
......@@ -705,8 +743,8 @@ public:
original.wrapped = nullptr;
original.value.wrapped = nullptr;
original.data_type.wrapped = nullptr;
this->properties = std::move(original.properties);
this->parents = std::move(original.parents);
original.properties.wrapped = nullptr;
original.parents.wrapped = nullptr;
this->errors = std::move(original.errors);
this->warnings = std::move(original.warnings);
this->infos = std::move(original.infos);
......
......@@ -52,6 +52,7 @@
#include <boost/filesystem/fstream.hpp> // for ifstream
#include <boost/filesystem/operations.hpp> // for exists
#include <boost/filesystem/path.hpp> // for path
#include <cstddef> // for size_t
#include <fstream> // for ifstream, size_t
#include <string> // for string
......
attrs==21.2.0
bottle==0.12.19
certifi==2021.5.30
certifi==2021.10.8
chardet==4.0.0
charset-normalizer==2.0.7
colorama==0.4.4
conan==1.40.3
deprecation==2.0.7
distro==1.5.0
conan==1.41.0
deprecation==2.1.0
distro==1.6.0
fasteners==0.16.3
future==0.18.2
idna==2.10
idna==3.2
Jinja2==2.11.3
jsonschema==3.2.0
jsonschema==4.1.0
MarkupSafe==2.0.1
node-semver==0.6.1
packaging==20.9
packaging==21.0
patch-ng==1.17.4
pluginbase==1.0.1
Pygments==2.9.0
Pygments==2.10.0
PyJWT==1.7.1
pyparsing==2.4.7
pyrsistent==0.18.0
python-dateutil==2.8.1
python-dateutil==2.8.2
PyYAML==5.4.1
requests==2.25.1
six==1.15.0
tqdm==4.61.1
urllib3==1.25.11
requests==2.26.0
six==1.16.0
tqdm==4.62.3
urllib3==1.26.7
......@@ -41,7 +41,7 @@ set(test_cases
# special linting for tests
set(_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS
"${_CMAKE_CXX_CLANG_TIDY_CHECKS},-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes"
"${_CMAKE_CXX_CLANG_TIDY_CHECKS},-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-clang-analyzer-cplusplus.Move"
)
# add special cmake functions for gtest
......
......@@ -129,4 +129,54 @@ TEST(test_data_type, test_data_type_to_string) {
EXPECT_EQ(data_type3.ToString(), "{\n \"atomicDataType\": \"ATOMIC_DATA_TYPE_INTEGER\"\n}\n");
}
TEST(test_data_type, data_type_copy_constructor) {
DataType data_type("person", true);
const auto dt_string = data_type.ToString();
// copy
const DataType copy_data_type(data_type); // NOLINT (explicit copy)
EXPECT_EQ(copy_data_type, data_type);
EXPECT_EQ(dt_string, copy_data_type.ToString());
}
TEST(test_data_type, data_type_move_constructor) {
DataType data_type("person", true);
const auto dt_string = data_type.ToString();
// copy for testing
const DataType copy_data_type(data_type);
// move
const DataType move_data_type(std::move(data_type)); // NOLINT
EXPECT_NE(data_type, copy_data_type); // NOLINT
EXPECT_NE(data_type.ToString(), dt_string); // NOLINT
EXPECT_EQ(copy_data_type, move_data_type);
EXPECT_EQ(move_data_type.ToString(), dt_string);
}
TEST(test_data_type, data_type_copy_assignment) {
DataType data_type("person", true);
const auto dt_string = data_type.ToString();
// copy
DataType copy_data_type = data_type; // NOLINT (explicit copy)
EXPECT_EQ(copy_data_type, data_type);
EXPECT_EQ(dt_string, copy_data_type.ToString());
}
TEST(test_data_type, data_type_move_assignment) {
DataType data_type("person", true);
const auto dt_string = data_type.ToString();
// copy for testing
const DataType copy_data_type(data_type);
// move
DataType move_data_type = std::move(data_type); // NOLINT
EXPECT_NE(data_type, copy_data_type); // NOLINT
EXPECT_NE(data_type.ToString(), dt_string); // NOLINT
EXPECT_EQ(copy_data_type, move_data_type);
EXPECT_EQ(move_data_type.ToString(), dt_string);
}
} // namespace caosdb::entity
......@@ -142,7 +142,7 @@ TEST(test_entity, test_append_property) {
EXPECT_EQ(prop.GetDataType(), same_prop.GetDataType());
}
TEST(test_entity, test_copy_constructor) {
TEST(test_entity, entity_copy_constructor) {
ProtoParent parent;
parent.set_description("the parent desc");
parent.set_id("the parent id");
......@@ -197,7 +197,7 @@ TEST(test_entity, test_copy_constructor) {
EXPECT_NE(this_entity.ToString(), copy_entity.ToString());
}
TEST(test_entity, test_move_constructor) {
TEST(test_entity, entity_move_constructor) {
ProtoParent parent;
parent.set_description("the parent desc");
parent.set_id("the parent id");
......@@ -263,7 +263,7 @@ TEST(test_entity, test_move_constructor) {
EXPECT_NE(move_entity.ToString(), copy_entity.ToString());
}
TEST(test_entity, test_property_copy_constructor) {
TEST(test_entity, property_copy_constructor) {
Property prop;
prop.SetName("prop_name");
prop.SetId("prop_id");
......@@ -283,7 +283,7 @@ TEST(test_entity, test_property_copy_constructor) {
EXPECT_EQ(prop.GetDataType(), other_prop.GetDataType());
}
TEST(test_entity, test_property_copy_assignment) {
TEST(test_entity, property_copy_assignment) {
Property prop;
prop.SetName("prop_name");
prop.SetId("prop_id");
......@@ -308,7 +308,7 @@ TEST(test_entity, test_property_copy_assignment) {
EXPECT_EQ(other_prop.GetName(), "other_prop_name");
}
TEST(test_entity, test_property_move_assignment) {
TEST(test_entity, property_move_assignment) {
Property prop;
prop.SetName("prop_name");
prop.SetId("prop_id");
......@@ -343,6 +343,127 @@ TEST(test_entity, test_property_move_assignment) {
EXPECT_EQ(other_prop.GetName(), "other_prop_name");
}
TEST(test_entity, property_move_constructor) {
Property prop;
prop.SetName("prop_name");
prop.SetId("prop_id");
prop.SetImportance(Importance::RECOMMENDED);
prop.SetValue("prop_value");
prop.SetUnit("prop_unit");
prop.SetDataType("prop_dtype");
const auto prop_string = prop.ToString();
// we compare the moved one with this one
const Property copy_prop(prop);
Property other_prop(std::move(prop));
EXPECT_NE(prop, copy_prop); // NOLINT
EXPECT_NE(prop, other_prop); // NOLINT
EXPECT_NE(prop.ToString(), prop_string); // NOLINT
EXPECT_EQ(copy_prop.ToString(), prop_string);
EXPECT_EQ(other_prop.ToString(), prop_string);
EXPECT_EQ(copy_prop, other_prop);
EXPECT_EQ(copy_prop.GetName(), other_prop.GetName());
EXPECT_EQ(copy_prop.GetId(), other_prop.GetId());
EXPECT_EQ(copy_prop.GetImportance(), other_prop.GetImportance());
EXPECT_EQ(copy_prop.GetValue().ToString(), other_prop.GetValue().ToString());
EXPECT_EQ(copy_prop.GetUnit(), other_prop.GetUnit());
EXPECT_EQ(copy_prop.GetDataType(), other_prop.GetDataType());
other_prop.SetName("other_prop_name");
EXPECT_NE(copy_prop, other_prop);
EXPECT_NE(copy_prop.GetName(), other_prop.GetName());
EXPECT_EQ(copy_prop.GetName(), "prop_name");
EXPECT_EQ(other_prop.GetName(), "other_prop_name");
}
TEST(test_entity, parent_copy_constructor) {
Parent parent;
parent.SetId("par_id");
parent.SetName("par_name");
// copy
const Parent copy_parent(parent);
EXPECT_EQ(copy_parent, parent);
EXPECT_EQ(copy_parent.GetId(), parent.GetId());
EXPECT_EQ(copy_parent.GetName(), parent.GetName());
// change something
parent.SetName("new_name");
EXPECT_NE(copy_parent, parent);
EXPECT_EQ(copy_parent.GetId(), parent.GetId());
EXPECT_NE(copy_parent.GetName(), parent.GetName());
}
TEST(test_entity, parent_move_constructor) {
Parent parent;
parent.SetId("par_id");
parent.SetName("par_name");
const auto parent_string = parent.ToString();
// copy for testing
const Parent copy_parent = parent;
// move
Parent move_parent(std::move(parent));
EXPECT_NE(parent, copy_parent); // NOLINT
EXPECT_NE(parent, move_parent); // NOLINT
EXPECT_NE(parent.ToString(), parent_string); // NOLINT
EXPECT_EQ(copy_parent, move_parent);
EXPECT_EQ(copy_parent.GetId(), move_parent.GetId());
EXPECT_EQ(copy_parent.GetName(), move_parent.GetName());
// change something
move_parent.SetName("new_name");
EXPECT_NE(copy_parent, move_parent);
EXPECT_EQ(copy_parent.GetId(), move_parent.GetId());
EXPECT_NE(copy_parent.GetName(), move_parent.GetName());
}
TEST(test_entity, parent_copy_assignment) {
Parent parent;
parent.SetId("par_id");
parent.SetName("par_name");
// copy
const Parent copy_parent = parent;
EXPECT_EQ(copy_parent, parent);
EXPECT_EQ(copy_parent.GetId(), parent.GetId());
EXPECT_EQ(copy_parent.GetName(), parent.GetName());
// change something
parent.SetName("new_name");
EXPECT_NE(copy_parent, parent);
EXPECT_EQ(copy_parent.GetId(), parent.GetId());
EXPECT_NE(copy_parent.GetName(), parent.GetName());
}
TEST(test_entity, parent_move_assignment) {
Parent parent;
parent.SetId("par_id");
parent.SetName("par_name");
const auto parent_string = parent.ToString();
// copy for testing
const Parent copy_parent = parent;
// move
Parent move_parent = std::move(parent);
EXPECT_NE(parent, copy_parent); // NOLINT
EXPECT_NE(parent, move_parent); // NOLINT
EXPECT_NE(parent.ToString(), parent_string); // NOLINT
EXPECT_EQ(copy_parent, move_parent);
EXPECT_EQ(copy_parent.GetId(), move_parent.GetId());
EXPECT_EQ(copy_parent.GetName(), move_parent.GetName());
// change something
move_parent.SetName("new_name");
EXPECT_NE(copy_parent, move_parent);
EXPECT_EQ(copy_parent.GetId(), move_parent.GetId());
EXPECT_NE(copy_parent.GetName(), move_parent.GetName());
}
TEST(test_entity, test_copy_to) {
auto entity = Entity();
entity.SetRole(Role::RECORD);
......@@ -693,7 +814,7 @@ TEST(test_entity, test_add_file) {
EXPECT_EQ(entity.SetLocalPath(TEST_DATA_DIR + "/test.json"), StatusCode::SUCCESS);
}
TEST(test_entity, test_move_assign) {
TEST(test_entity, entity_move_assignment) {
Entity entity1;
entity1.SetRole(Role::RECORD_TYPE);
entity1.SetName("E1");
......@@ -757,8 +878,8 @@ TEST(test_entity, test_property_to_string) {
EXPECT_EQ(property.ToString(), "{}\n");
property.SetDataType(AtomicDataType::DOUBLE);
EXPECT_EQ(property.ToString(),
"{\n \"dataType\": {\n \"atomicDataType\": \"ATOMIC_DATA_TYPE_DOUBLE\"\n }\n}\n");
EXPECT_EQ(property.ToString(), "{\n \"dataType\": {\n \"atomicDataType\": "
"\"ATOMIC_DATA_TYPE_DOUBLE\"\n }\n}\n");
}
TEST(test_entity, test_parents_to_string) {
......
......@@ -188,9 +188,9 @@ TEST(test_value, test_value_to_string) {
EXPECT_EQ(value3.ToString(), "{\n \"scalarValue\": {\n \"doubleValue\": 2.6\n }\n}\n");
Value value4(std::vector<bool>{true, false});
EXPECT_EQ(value4.ToString(),
"{\n \"listValues\": {\n \"values\": [\n {\n \"booleanValue\": true\n },\n "
"{\n \"booleanValue\": false\n }\n ]\n }\n}\n");
EXPECT_EQ(value4.ToString(), "{\n \"listValues\": {\n \"values\": [\n {\n "
"\"booleanValue\": true\n },\n "
"{\n \"booleanValue\": false\n }\n ]\n }\n}\n");
}
} // namespace caosdb::entity