7#include <PhosphorAnimation/phosphoranimation_export.h>
25 using Factory = std::function<std::shared_ptr<const Curve>(
const QString& typeId,
const QString& params)>;
28 using JsonFactory = std::function<std::shared_ptr<const Curve>(
const QJsonObject& parameters)>;
41 const QString& ownerTag);
51 std::shared_ptr<const Curve>
create(
const QString& spec)
const;
54 std::shared_ptr<const Curve>
tryCreate(
const QString& spec)
const;
57 std::shared_ptr<const Curve>
tryCreateFromJson(
const QString& typeId,
const QJsonObject& parameters)
const;
63 bool has(
const QString& typeId)
const;
76 std::unique_ptr<Impl> m_impl;
String-id <-> curve factory registry.
Definition CurveRegistry.h:22
bool registerFactory(const QString &typeId, Factory factory, const QString &ownerTag)
Register a tagged factory. Tagged entries are bulk-removable via unregisterByOwner.
CurveRegistry(CurveRegistry &&)=delete
bool has(const QString &typeId) const
True if typeId has a registered factory.
static bool isBuiltinTypeId(const QString &typeId)
True if typeId names a built-in factory (auto-registered by constructor).
std::shared_ptr< const Curve > create(const QString &spec) const
Parse spec ("typeId:params" or "x1,y1,x2,y2") into a curve.
bool registerFactory(const QString &typeId, Factory stringFactory, JsonFactory jsonFactory, const QString &ownerTag)
Register both string-form and JSON-parameter factories.
bool registerFactory(const QString &typeId, Factory factory)
Register an untagged factory for typeId. Replaces prior registration.
QStringList knownTypes() const
All registered typeIds in insertion order.
CurveRegistry & operator=(CurveRegistry &&)=delete
CurveRegistry & operator=(const CurveRegistry &)=delete
std::function< std::shared_ptr< const Curve >(const QString &typeId, const QString ¶ms)> Factory
String-form factory: receives typeId + parameter substring after the colon.
Definition CurveRegistry.h:25
int unregisterByOwner(const QString &ownerTag)
Remove every factory matching ownerTag. Empty tag is rejected.
std::shared_ptr< const Curve > tryCreateFromJson(const QString &typeId, const QJsonObject ¶meters) const
Build a curve from typeId + JSON parameters. Returns nullptr on failure.
std::function< std::shared_ptr< const Curve >(const QJsonObject ¶meters)> JsonFactory
JSON factory: receives parameter fields, returns curve or nullptr on validation failure.
Definition CurveRegistry.h:28
std::shared_ptr< const Curve > tryCreate(const QString &spec) const
Like create() but returns nullptr on any failure.
bool unregisterFactory(const QString &typeId)
Remove a previously-registered factory. No-op if not registered.
CurveRegistry(const CurveRegistry &)=delete
Definition AnimatedValue.h:31