String-id <-> curve factory registry. More...
#include <phosphor-animation/include/PhosphorAnimation/CurveRegistry.h>
Public Types | |
| using | Factory = std::function< std::shared_ptr< const Curve >(const QString &typeId, const QString ¶ms)> |
| String-form factory: receives typeId + parameter substring after the colon. | |
| using | JsonFactory = std::function< std::shared_ptr< const Curve >(const QJsonObject ¶meters)> |
| JSON factory: receives parameter fields, returns curve or nullptr on validation failure. | |
Public Member Functions | |
| CurveRegistry () | |
| ~CurveRegistry () | |
| bool | registerFactory (const QString &typeId, Factory factory) |
Register an untagged factory for typeId. Replaces prior registration. | |
| bool | registerFactory (const QString &typeId, Factory factory, const QString &ownerTag) |
| Register a tagged factory. Tagged entries are bulk-removable via unregisterByOwner. | |
| bool | registerFactory (const QString &typeId, Factory stringFactory, JsonFactory jsonFactory, const QString &ownerTag) |
| Register both string-form and JSON-parameter factories. | |
| bool | unregisterFactory (const QString &typeId) |
| Remove a previously-registered factory. No-op if not registered. | |
| int | unregisterByOwner (const QString &ownerTag) |
Remove every factory matching ownerTag. Empty tag is rejected. | |
| std::shared_ptr< const Curve > | create (const QString &spec) const |
Parse spec ("typeId:params" or "x1,y1,x2,y2") into a curve. | |
| std::shared_ptr< const Curve > | tryCreate (const QString &spec) const |
| Like create() but returns nullptr on any failure. | |
| std::shared_ptr< const Curve > | tryCreateFromJson (const QString &typeId, const QJsonObject ¶meters) const |
Build a curve from typeId + JSON parameters. Returns nullptr on failure. | |
| QStringList | knownTypes () const |
| All registered typeIds in insertion order. | |
| bool | has (const QString &typeId) const |
True if typeId has a registered factory. | |
| CurveRegistry (const CurveRegistry &)=delete | |
| CurveRegistry & | operator= (const CurveRegistry &)=delete |
| CurveRegistry (CurveRegistry &&)=delete | |
| CurveRegistry & | operator= (CurveRegistry &&)=delete |
Static Public Member Functions | |
| static bool | isBuiltinTypeId (const QString &typeId) |
True if typeId names a built-in factory (auto-registered by constructor). | |
String-id <-> curve factory registry.
Enables config round-trip ("typeId:params" strings) and third-party curve extension at runtime. Thread-safe (internal QMutex). Per-process instance, owned by composition root.
| using PhosphorAnimation::CurveRegistry::Factory = std::function<std::shared_ptr<const Curve>(const QString& typeId, const QString& params)> |
String-form factory: receives typeId + parameter substring after the colon.
| using PhosphorAnimation::CurveRegistry::JsonFactory = std::function<std::shared_ptr<const Curve>(const QJsonObject& parameters)> |
JSON factory: receives parameter fields, returns curve or nullptr on validation failure.
| PhosphorAnimation::CurveRegistry::CurveRegistry | ( | ) |
| PhosphorAnimation::CurveRegistry::~CurveRegistry | ( | ) |
|
delete |
|
delete |
| std::shared_ptr< const Curve > PhosphorAnimation::CurveRegistry::create | ( | const QString & | spec | ) | const |
Parse spec ("typeId:params" or "x1,y1,x2,y2") into a curve.
Never returns nullptr — falls back to OutCubic on failure.
| bool PhosphorAnimation::CurveRegistry::has | ( | const QString & | typeId | ) | const |
True if typeId has a registered factory.
|
static |
True if typeId names a built-in factory (auto-registered by constructor).
CurveLoader uses this to reject user JSON files that would shadow built-ins.
| QStringList PhosphorAnimation::CurveRegistry::knownTypes | ( | ) | const |
All registered typeIds in insertion order.
|
delete |
|
delete |
| bool PhosphorAnimation::CurveRegistry::registerFactory | ( | const QString & | typeId, |
| Factory | factory | ||
| ) |
Register an untagged factory for typeId. Replaces prior registration.
| bool PhosphorAnimation::CurveRegistry::registerFactory | ( | const QString & | typeId, |
| Factory | factory, | ||
| const QString & | ownerTag | ||
| ) |
Register a tagged factory. Tagged entries are bulk-removable via unregisterByOwner.
| bool PhosphorAnimation::CurveRegistry::registerFactory | ( | const QString & | typeId, |
| Factory | stringFactory, | ||
| JsonFactory | jsonFactory, | ||
| const QString & | ownerTag | ||
| ) |
Register both string-form and JSON-parameter factories.
| std::shared_ptr< const Curve > PhosphorAnimation::CurveRegistry::tryCreate | ( | const QString & | spec | ) | const |
Like create() but returns nullptr on any failure.
| std::shared_ptr< const Curve > PhosphorAnimation::CurveRegistry::tryCreateFromJson | ( | const QString & | typeId, |
| const QJsonObject & | parameters | ||
| ) | const |
Build a curve from typeId + JSON parameters. Returns nullptr on failure.
| int PhosphorAnimation::CurveRegistry::unregisterByOwner | ( | const QString & | ownerTag | ) |
Remove every factory matching ownerTag. Empty tag is rejected.
| bool PhosphorAnimation::CurveRegistry::unregisterFactory | ( | const QString & | typeId | ) |
Remove a previously-registered factory. No-op if not registered.