10#include <spdlog/spdlog.h>
15std::unordered_map<WorkerType, WorkerBuilder::CreatorFunc>& WorkerBuilder::getRegistry()
18 static std::unordered_map<WorkerType, CreatorFunc> registry;
25 getRegistry()[type] = std::move(creator);
30 auto& registry = getRegistry();
31 auto it = registry.find(type);
34 if (it == registry.end())
36 spdlog::error(
"[WorkerBuilder] No creator registered for worker type: {}",
static_cast<int>(type));
46 catch (
const std::exception& e)
48 spdlog::critical(
"[WorkerBuilder] Exception during instantiation of worker type {}: {}",
49 static_cast<int>(type), e.what());
std::function< std::unique_ptr< IWorkerRequest >()> CreatorFunc
Definition of the creator function signature.
static std::unique_ptr< IWorkerRequest > build(WorkerType type)
Retrieves an instance of the worker for the specified type.
static void registerCreator(WorkerType type, CreatorFunc creator)
Registers a creator function for a specific worker type.
WorkerType
Identifies the specific technology or strategy used for a processing worker.
Central Registry and Factory for IWorkerRequest instances.