Skip to content
Snippets Groups Projects
Commit 3bab18bd authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Prevent creation of base StateBlock

parent 78d9b8da
No related branches found
No related tags found
2 merge requests!466devel->main,!456Resolve "Migrate from StateBlock to StateDerived"
...@@ -136,19 +136,6 @@ inline std::string FactoryStateBlock::getClass() const ...@@ -136,19 +136,6 @@ inline std::string FactoryStateBlock::getClass() const
return "FactoryStateBlock"; return "FactoryStateBlock";
} }
template<>
inline StateBlockPtr FactoryStateBlock::create(const string& _type, const Eigen::VectorXd& _state, bool _fixed)
{
typename CallbackMap::const_iterator creator_callback_it = get().callbacks_.find(_type);
if (creator_callback_it == get().callbacks_.end())
// not found: return StateBlock base
return std::make_shared<StateBlock>(_state, _fixed);
// Invoke the creation function
return (creator_callback_it->second)(_state, _fixed);
}
#define WOLF_REGISTER_STATEBLOCK(StateBlockType) \ #define WOLF_REGISTER_STATEBLOCK(StateBlockType) \
namespace \ namespace \
{ \ { \
......
...@@ -194,8 +194,6 @@ public: ...@@ -194,8 +194,6 @@ public:
bool isValid(double tolerance = Constants::EPS); bool isValid(double tolerance = Constants::EPS);
static StateBlockPtr create (const Eigen::VectorXd& _state, bool _fixed = false);
}; };
...@@ -350,10 +348,6 @@ inline Eigen::VectorXd StateBlock::zero() const ...@@ -350,10 +348,6 @@ inline Eigen::VectorXd StateBlock::zero() const
return identity(); return identity();
} }
inline StateBlockPtr StateBlock::create (const Eigen::VectorXd& _state, bool _fixed)
{
return std::make_shared<StateBlock>(_state, _fixed);
}
inline bool StateBlock::isValid(double tolerance) inline bool StateBlock::isValid(double tolerance)
{ {
return local_param_ptr_ ? local_param_ptr_->isValid(state_, tolerance) : true; return local_param_ptr_ ? local_param_ptr_->isValid(state_, tolerance) : true;
......
...@@ -36,55 +36,11 @@ ...@@ -36,55 +36,11 @@
using namespace wolf; using namespace wolf;
/*
// You may use this to make some methods of Foo public
WOLF_PTR_TYPEDEFS(FooPublic);
class FooPublic : public Foo
{
// You may use this to make some methods of Foo public
}
class TestInit : public testing::Test
{
public:
// You may use this to initialize stuff
// Combine it with TEST_F(FooTest, testName) { }
void SetUp() override
{
// Init all you want here
// e.g. FooPublic foo;
}
void TearDown() override {} // you can delete this if unused
};
TEST_F(TestInit, testName)
{
// Use class TestInit
}
*/
//TEST(FactoryStateBlock, get_getClass)
//{
// const auto& f = FactoryStateBlock::get();
//
// const std::string& s = f.getClass();
//
// ASSERT_EQ(s, "FactoryStateBlock");
//}
TEST(FactoryStateBlock, creator_default) TEST(FactoryStateBlock, creator_non_registered)
{ {
auto sbp = FactoryStateBlock::create("P", Eigen::Vector3d(1,2,3), false); // non registered -> throw
auto sbv = FactoryStateBlock::create("V", Eigen::Vector2d(4,5), false); ASSERT_THROW(auto sba = FactoryStateBlock::create("A", Eigen::Vector1d(6), false), std::runtime_error);
auto sbw = FactoryStateBlock::create("W", Eigen::Vector1d(6), false);
ASSERT_MATRIX_APPROX(Eigen::Vector3d(1,2,3) , sbp->getState(), 1e-20);
ASSERT_MATRIX_APPROX(Eigen::Vector2d(4,5) , sbv->getState(), 1e-20);
ASSERT_MATRIX_APPROX(Eigen::Vector1d(6) , sbw->getState(), 1e-20);
ASSERT_FALSE(sbp->hasLocalParametrization());
ASSERT_FALSE(sbv->hasLocalParametrization());
ASSERT_FALSE(sbw->hasLocalParametrization());
} }
TEST(FactoryStateBlock, creator_StateBlock) TEST(FactoryStateBlock, creator_StateBlock)
......
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