Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/triggeralgs/AbstractFactory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ template <typename T>
void AbstractFactory<T>::register_creator(const std::string alg_name, maker_creator creator)
{
creation_map& makers = get_makers();

// Check invalid state in the map
for (const auto& pair : makers) {
if (!pair.second) { // nullptr or invalid
throw FactoryInvalidState(ERS_HERE, alg_name);
}
}

auto it = makers.find(alg_name);

if (it == makers.end()) {
Expand Down
5 changes: 5 additions & 0 deletions include/triggeralgs/Issues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ ERS_DECLARE_ISSUE(triggeralgs,
"Attempted to overwrite a creator in factory with " << alg_name,
((std::string)alg_name))

ERS_DECLARE_ISSUE(triggeralgs,
FactoryInvalidState,
"Makers map contains invalid/null pointers " << alg_name,
((std::string)alg_name))

ERS_DECLARE_ISSUE(triggeralgs,
FactoryNotFound,
"Factory couldn't find: " << alg_name,
Expand Down