Generic factory template for file-format-specific product creation. More...
#include <fileformatfactory.h>

Classes | |
| struct | Context |
| Context passed to factory methods for lookup and creation. More... | |
Public Member Functions | |
| FileFormatFactory ()=default | |
| Default constructor. | |
| virtual | ~FileFormatFactory () |
| Virtual destructor. | |
| String | name () const |
| Returns the human-readable name of this factory. | |
| const StringList & | extensions () const |
| Returns the list of supported file extensions. | |
| bool | isExtensionSupported (const String &filename) const |
| Returns true if the filename has a supported extension. | |
| bool | isHintSupported (const String &hint) const |
| Returns true if the hint matches a supported extension. | |
| virtual bool | canDoOperation (const Context &ctx) const |
| Returns true if this factory can handle the given context. | |
| virtual Result< Product > | createForOperation (const Context &ctx) const |
| Creates a Product configured for the given context. | |
Static Public Member Functions | |
| static int | registerFactory (FileFormatFactory *factory) |
| Registers a factory instance in the global registry. | |
| static const FileFormatFactory * | lookup (const Context &ctx) |
| Looks up a factory that can handle the given context. | |
Protected Attributes | |
| String | _name |
| Human-readable factory name. | |
| StringList | _exts |
| List of supported file extensions (no dots). | |
Generic factory template for file-format-specific product creation.
FileFormatFactory captures the registry/lookup pattern used by audio and image file backends. Subclasses register themselves at static init time via PROMEKI_REGISTER_FILE_FORMAT_FACTORY and override canDoOperation() and createForOperation() to handle specific file formats.
| Product | The type that factories create (e.g. AudioFile). |
|
inlinevirtual |
Returns true if this factory can handle the given context.
Subclasses override this to inspect the context and decide whether they can perform the requested operation.
| ctx | The context describing the requested operation. |
|
inlinevirtual |
Creates a Product configured for the given context.
Subclasses override this to instantiate their backend.
| ctx | The context describing the requested operation. |
|
inline |
Returns the list of supported file extensions.
|
inline |
Returns true if the filename has a supported extension.
| filename | The path to check. |
|
inline |
Returns true if the hint matches a supported extension.
| hint | The format hint string (e.g. "wav"), no dot. |
|
inlinestatic |
Looks up a factory that can handle the given context.
Iterates registered factories, calling canDoOperation() on each. Returns the first match or nullptr if none found.
| ctx | The context describing the requested operation. |
|
inline |
Returns the human-readable name of this factory.
|
inlinestatic |
Registers a factory instance in the global registry.
| factory | Pointer to the factory to register. Ownership is taken. |