Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorAnimation::CurveRegistry Class Reference

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 &params)>
 String-form factory: receives typeId + parameter substring after the colon.
 
using JsonFactory = std::function< std::shared_ptr< const Curve >(const QJsonObject &parameters)>
 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 Curvecreate (const QString &spec) const
 Parse spec ("typeId:params" or "x1,y1,x2,y2") into a curve.
 
std::shared_ptr< const CurvetryCreate (const QString &spec) const
 Like create() but returns nullptr on any failure.
 
std::shared_ptr< const CurvetryCreateFromJson (const QString &typeId, const QJsonObject &parameters) 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
 
CurveRegistryoperator= (const CurveRegistry &)=delete
 
 CurveRegistry (CurveRegistry &&)=delete
 
CurveRegistryoperator= (CurveRegistry &&)=delete
 

Static Public Member Functions

static bool isBuiltinTypeId (const QString &typeId)
 True if typeId names a built-in factory (auto-registered by constructor).
 

Detailed Description

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.

Member Typedef Documentation

◆ Factory

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.

◆ JsonFactory

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.

Constructor & Destructor Documentation

◆ CurveRegistry() [1/3]

PhosphorAnimation::CurveRegistry::CurveRegistry ( )

◆ ~CurveRegistry()

PhosphorAnimation::CurveRegistry::~CurveRegistry ( )

◆ CurveRegistry() [2/3]

PhosphorAnimation::CurveRegistry::CurveRegistry ( const CurveRegistry )
delete

◆ CurveRegistry() [3/3]

PhosphorAnimation::CurveRegistry::CurveRegistry ( CurveRegistry &&  )
delete

Member Function Documentation

◆ create()

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.

◆ has()

bool PhosphorAnimation::CurveRegistry::has ( const QString &  typeId) const

True if typeId has a registered factory.

◆ isBuiltinTypeId()

static bool PhosphorAnimation::CurveRegistry::isBuiltinTypeId ( const QString &  typeId)
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.

◆ knownTypes()

QStringList PhosphorAnimation::CurveRegistry::knownTypes ( ) const

All registered typeIds in insertion order.

◆ operator=() [1/2]

CurveRegistry & PhosphorAnimation::CurveRegistry::operator= ( const CurveRegistry )
delete

◆ operator=() [2/2]

CurveRegistry & PhosphorAnimation::CurveRegistry::operator= ( CurveRegistry &&  )
delete

◆ registerFactory() [1/3]

bool PhosphorAnimation::CurveRegistry::registerFactory ( const QString &  typeId,
Factory  factory 
)

Register an untagged factory for typeId. Replaces prior registration.

◆ registerFactory() [2/3]

bool PhosphorAnimation::CurveRegistry::registerFactory ( const QString &  typeId,
Factory  factory,
const QString &  ownerTag 
)

Register a tagged factory. Tagged entries are bulk-removable via unregisterByOwner.

◆ registerFactory() [3/3]

bool PhosphorAnimation::CurveRegistry::registerFactory ( const QString &  typeId,
Factory  stringFactory,
JsonFactory  jsonFactory,
const QString &  ownerTag 
)

Register both string-form and JSON-parameter factories.

◆ tryCreate()

std::shared_ptr< const Curve > PhosphorAnimation::CurveRegistry::tryCreate ( const QString &  spec) const

Like create() but returns nullptr on any failure.

◆ tryCreateFromJson()

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.

◆ unregisterByOwner()

int PhosphorAnimation::CurveRegistry::unregisterByOwner ( const QString &  ownerTag)

Remove every factory matching ownerTag. Empty tag is rejected.

◆ unregisterFactory()

bool PhosphorAnimation::CurveRegistry::unregisterFactory ( const QString &  typeId)

Remove a previously-registered factory. No-op if not registered.


The documentation for this class was generated from the following file: