diff --git a/include/core/state_block/factory_state_block.h b/include/core/state_block/factory_state_block.h index a5cce9d4830dbe1879fe78755574f6fd14398132..5c90da7b1c297d89b9db00364008e696e7316cfa 100644 --- a/include/core/state_block/factory_state_block.h +++ b/include/core/state_block/factory_state_block.h @@ -136,19 +136,6 @@ inline std::string FactoryStateBlock::getClass() const 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) \ namespace \ { \ diff --git a/include/core/state_block/state_block.h b/include/core/state_block/state_block.h index 3cbced5e7f2998a881fb2e116861e7b53779d676..78fa9812713146ee211426ea6d1e58296519b51f 100644 --- a/include/core/state_block/state_block.h +++ b/include/core/state_block/state_block.h @@ -194,8 +194,6 @@ public: 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 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) { return local_param_ptr_ ? local_param_ptr_->isValid(state_, tolerance) : true; diff --git a/test/gtest_factory_state_block.cpp b/test/gtest_factory_state_block.cpp index a7bfa9c963ad52a55d89d6f713c35c2223c69c66..5d3b3e20453c1ce809483ada9f074557c3063f72 100644 --- a/test/gtest_factory_state_block.cpp +++ b/test/gtest_factory_state_block.cpp @@ -36,55 +36,11 @@ 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); - auto sbv = FactoryStateBlock::create("V", Eigen::Vector2d(4,5), false); - 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()); + // non registered -> throw + ASSERT_THROW(auto sba = FactoryStateBlock::create("A", Eigen::Vector1d(6), false), std::runtime_error); } TEST(FactoryStateBlock, creator_StateBlock)