Skip to content
Snippets Groups Projects
Commit 0d934b0f authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Remove unnecessary overrides of copy(), add tests for checking whether copy() exists

parent a06a5498
No related branches found
No related tags found
2 merge requests!140armem/dev -> master,!139Refactor inheritance in armem/core
......@@ -268,33 +268,6 @@ namespace armarx::armem::base
return "entity";
}
virtual _Derived copy() const override
{
_Derived d;
this->_copySelf(d);
return d;
}
virtual _Derived copyEmpty() const override
{
_Derived d;
this->_copySelfEmpty(d);
return d;
}
protected:
virtual void _copySelf(DerivedT& other) const override
{
Base::_copySelf(other);
}
virtual void _copySelfEmpty(DerivedT& other) const override
{
Base::_copySelfEmpty(other);
}
private:
......
......@@ -46,14 +46,6 @@ namespace armarx::armem::base
return id().instanceIndex;
}
// Copying
virtual DerivedT copy() const
{
DerivedT d;
this->_copySelf(d);
return d;
}
/**
* @brief Fill `*this` with the update's values.
* @param update The update.
......@@ -64,6 +56,13 @@ namespace armarx::armem::base
virtual bool equalsDeep(const DerivedT& other) const = 0;
virtual DerivedT copy() const
{
DerivedT d;
this->_copySelf(d);
return d;
}
std::string getLevelName() const override
{
......
......@@ -766,3 +766,53 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment)
}
}
template <class T>
struct CopyTest
{
CopyTest()
{
}
void test()
{
// At least check whether they can be called.
T t;
T t2 = t.copy();
if constexpr (std::is_base_of_v<armem::base::EntityInstanceBase<T>, T>)
{
t2 = t.copyEmpty();
}
}
};
BOOST_AUTO_TEST_CASE(test_copy)
{
{
CopyTest<armem::wm::EntityInstance>().test();
CopyTest<armem::wm::EntitySnapshot>().test();
CopyTest<armem::wm::Entity>().test();
CopyTest<armem::wm::ProviderSegment>().test();
CopyTest<armem::wm::CoreSegment>().test();
CopyTest<armem::wm::Memory>().test();
}
{
CopyTest<armem::ltm::EntityInstance>().test();
CopyTest<armem::ltm::EntitySnapshot>().test();
CopyTest<armem::ltm::Entity>().test();
CopyTest<armem::ltm::ProviderSegment>().test();
CopyTest<armem::ltm::CoreSegment>().test();
CopyTest<armem::ltm::Memory>().test();
}
{
CopyTest<armem::d_ltm::EntityInstance>().test();
CopyTest<armem::d_ltm::EntitySnapshot>().test();
CopyTest<armem::d_ltm::Entity>().test();
CopyTest<armem::d_ltm::ProviderSegment>().test();
CopyTest<armem::d_ltm::CoreSegment>().test();
CopyTest<armem::d_ltm::Memory>().test();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment