73 for (
size_t i = 0; i < MODULES_NUMBER; i++)
94 [[nodiscard]]
bool insert(T *element)
97 static_assert(std::is_base_of<Module, T>(),
98 "Class must be subclass of Module");
99 static_assert((std::is_same<Module, T>() ==
false),
100 "Class must be subclass of Module and not Module itself");
102 if (!insertionAcceptance)
105 "Cannot insert any other module after first get() call");
110 size_t id = getId<T>();
114 if (
id == MODULES_NUMBER)
121 if (modules[
id] ==
nullptr)
123 modules[id] = element;
141 static_assert(std::is_base_of<Module, T>(),
142 "Class must be subclass of Module");
143 static_assert((std::is_same<Module, T>() ==
false),
144 "Class must be subclass of Module and not Module itself");
147 insertionAcceptance =
false;
150 size_t id = getId<T>();
154 if (modules[
id] !=
nullptr)
156 return dynamic_cast<T *
>(modules[id]);
160 assert(
false &&
"Get of a non previously inserted module");
165 static constexpr size_t MODULES_NUMBER = 256;
168 std::array<Module *, MODULES_NUMBER> modules = {
nullptr};
177 std::atomic<bool> insertionAcceptance{
true};
188 static size_t currentId = 0;
190 if (currentId == MODULES_NUMBER)
192 return MODULES_NUMBER;
212 template <
typename T>
218 static size_t newId = getNextId();
virtual ~Module()=default
The module manager is a singleton object, so it can be instantiated only once. It contains all the ac...
T * get()
Get the Module object if present.
bool insert(T *element)
Inserts the module inside the array.
This file includes all the types the logdecoder script will decode.