Skip to content
Snippets Groups Projects
Commit 3cd5d50a authored by Jeremie Deray's avatar Jeremie Deray
Browse files

fix StateBlock notification mechanism

parent fb00557a
No related branches found
No related tags found
No related merge requests found
......@@ -113,6 +113,8 @@ public:
void removeLocalParametrization();
/// @todo Solely the solver should be able to
/// pass Notification::ENABLED !
void notify(const StateBlock::Notification n);
StateBlock::Notification notify() const noexcept;
......@@ -126,6 +128,7 @@ public:
namespace wolf {
inline StateBlock::StateBlock(const Eigen::VectorXs _state, bool _fixed, LocalParametrizationBasePtr _local_param_ptr) :
notification_(Notification::ADD),
node_ptr_(), // nullptr
fixed_(_fixed),
state_(_state),
......@@ -135,6 +138,7 @@ inline StateBlock::StateBlock(const Eigen::VectorXs _state, bool _fixed, LocalPa
}
inline StateBlock::StateBlock(const unsigned int _size, bool _fixed, LocalParametrizationBasePtr _local_param_ptr) :
notification_(Notification::ADD),
node_ptr_(), // nullptr
fixed_(_fixed),
state_(Eigen::VectorXs::Zero(_size)),
......@@ -216,7 +220,91 @@ inline void StateBlock::setLocalParametrizationPtr(LocalParametrizationBasePtr _
inline void StateBlock::notify(const StateBlock::Notification n)
{
notification_ = n;
/// @todo replace diz mess by a simple
/// extendable state-machine
switch (notification_)
{
case Notification::ADD:
{
switch (n)
{
case Notification::ADD:
case Notification::FIX_UPDATE:
case Notification::UPDATE: break; // if any of those 3, do nothing
case Notification::ENABLED:
case Notification::REMOVE: // if any of those 2, change notif
{
notification_ = n;
break;
}
}
break;
}
case Notification::ENABLED:
{
switch (n)
{
case Notification::ADD: //throw std::runtime_error("Tried to ADD again an existing StateBlock !"); break;
case Notification::ENABLED: break;
case Notification::REMOVE:
case Notification::FIX_UPDATE:
case Notification::UPDATE:
{
notification_ = n;
break;
}
}
break;
}
case Notification::FIX_UPDATE:
{
switch (n)
{
case Notification::ADD: //throw std::runtime_error("Tried to ADD again an existing StateBlock !"); break;
case Notification::FIX_UPDATE: break;
case Notification::UPDATE: // We should have UPDATE & FIX_UPDATE !
case Notification::REMOVE:
case Notification::ENABLED:
{
notification_ = n;
break;
}
}
break;
}
case Notification::REMOVE:
{
switch (n)
{
case Notification::ADD: /// @note moving from remove to add goes to add again ?
{
notification_ = Notification::ENABLED;
break;
}
case Notification::ENABLED: throw std::runtime_error("Tried to ENABLED a StateBlock marked for REMOVE!"); break;
case Notification::FIX_UPDATE: // We should have UPDATE & FIX_UPDATE !
case Notification::UPDATE:
case Notification::REMOVE: break;
}
break;
}
case Notification::UPDATE:
{
switch (n)
{
case Notification::ADD: //throw std::runtime_error("Tried to ADD again an existing StateBlock !"); break;
case Notification::UPDATE: break;
case Notification::FIX_UPDATE:
case Notification::REMOVE:
case Notification::ENABLED:
{
notification_ = n;
break;
}
}
break;
}
}
}
inline StateBlock::Notification StateBlock::notify() const noexcept
......
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