FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
stage_registry.h
Go to the documentation of this file.
1#pragma once
2
17#include "stage/stage.h"
18#include "fzm_format.h"
19
20#include <cstddef>
21#include <cstdint>
22
23namespace fz {
24
31using StageHeaderFactory = Stage* (*)(const uint8_t* config, size_t config_size);
32
35
38
44Stage* createStage(StageType type, const uint8_t* config, size_t config_size);
45
46namespace detail {
53} // namespace detail
54
55} // namespace fz
56
57/* Token-paste helpers so __LINE__ expands before concatenation. */
58#define FZ_STAGE_CONCAT_(a, b) a##b
59#define FZ_STAGE_CONCAT(a, b) FZ_STAGE_CONCAT_(a, b)
60
68#define FZ_REGISTER_STAGE_FACTORY(TYPE, FN) \
69 namespace { \
70 const ::fz::detail::StageFactoryRegistrar \
71 FZ_STAGE_CONCAT(FZ_STAGE_FACTORY_REGISTRAR_, __LINE__){(TYPE), (FN)}; \
72 }
73
80#define FZ_REGISTER_SIMPLE_STAGE(TYPE, STAGE_CLASS) \
81 namespace { \
82 ::fz::Stage* FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_FACTORY_, __LINE__)(const uint8_t* config, \
83 size_t config_size) { \
84 auto* s = new STAGE_CLASS(); \
85 s->deserializeHeader(config, config_size); \
86 return s; \
87 } \
88 const ::fz::detail::StageFactoryRegistrar \
89 FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_REGISTRAR_, __LINE__){(TYPE), \
90 &FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_FACTORY_, __LINE__)}; \
91 }
Definition stage.h:31
FZM binary file format definitions — structs, enums, and helpers.
Definition dag.h:24
Stage * createStage(StageType type, const uint8_t *config, size_t config_size)
bool hasStageHeaderFactory(StageType type)
StageType
Stage type identifiers written into the FZM header.
Definition fzm_format.h:88
void registerStageHeaderFactory(StageType type, StageHeaderFactory fn)
Stage *(*)(const uint8_t *config, size_t config_size) StageHeaderFactory
Definition stage_registry.h:31
Base class interface for all compression stages.
Definition stage_registry.h:48