2024-12-04 08:06:35 +00:00
|
|
|
#pragma once
|
2024-12-01 09:55:56 +00:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "processor.h"
|
|
|
|
|
|
|
|
// Processor Factory Class
|
|
|
|
class ProcessorFactory {
|
|
|
|
public:
|
2024-12-02 07:24:30 +00:00
|
|
|
using Creator = std::function<std::unique_ptr<Processor>(const ProcessorConfig &, uint32_t)>;
|
2024-12-01 09:55:56 +00:00
|
|
|
|
|
|
|
// Singleton instance accessor
|
|
|
|
static ProcessorFactory &instance();
|
|
|
|
|
|
|
|
// Register a processor type with its creation function
|
|
|
|
void register_processor(ProcessorType type, Creator creator);
|
|
|
|
|
|
|
|
// Create a processor instance based on configuration
|
|
|
|
std::unique_ptr<Processor>
|
2024-12-02 07:24:30 +00:00
|
|
|
create_processor(const ProcessorConfig &proc_cfg, uint32_t vk_device_index) const;
|
2024-12-01 09:55:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private constructor for Singleton
|
|
|
|
ProcessorFactory() = default;
|
|
|
|
|
|
|
|
// Map of processor types to their creation functions
|
|
|
|
std::unordered_map<ProcessorType, Creator> creators;
|
|
|
|
|
|
|
|
// Static initializer for default processors
|
|
|
|
static void init_default_processors(ProcessorFactory &factory);
|
|
|
|
};
|