Skip to content

Commit

Permalink
Do not allow roles to be updated once registered
Browse files Browse the repository at this point in the history
  • Loading branch information
mraduldubey committed Jul 30, 2024
1 parent 26bc046 commit 0450430
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions base/src/AbsControlModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,23 @@ void AbsControlModule::handleHealthCallback(const HealthObject& healthObj)

bool AbsControlModule::enrollModule(std::string role, boost::shared_ptr<Module> module)
{
if (moduleRoles.find(role) != moduleRoles.end())
{
throw AIPException(CTRL_MODULE_INVALID_STATE, "Role already registered with the control module.");
}

moduleRoles[role] = module;

// NOTE: If you want error callback and health callback to work with a module, registering it with control is mandatory.
module->registerErrorCallback(
[this](const ErrorObject& error) { handleError(error); });

if (module->getProps().enableHealthCallBack)
{
module->registerHealthCallback(
[this](const HealthObject& message) { handleHealthCallback(message); });
}

return true;
}

Expand Down

0 comments on commit 0450430

Please sign in to comment.