Backend Registry#
Backend Registry#
Lightweight in-memory registry for discoverable quantum backends and their factory constructors. Provides a unified mechanism to register, query, instantiate, and list available backends through a global module-level API.
- class qmlhc.core.registry.BackendRegistry[source]#
Bases:
objectIn-memory registry that stores and manages backend entries.
Methods allow registration, lookup, creation, and listing of all available backends.
- create(name, config)[source]#
Instantiate a backend by name.
- Parameters:
name (str) – Backend name to instantiate.
config (BackendConfig) – Configuration object to pass to the backend constructor.
- Returns:
New backend instance.
- Return type:
QuantumBackendProtocol
- register(name, constructor, capabilities, overwrite=False)[source]#
Register a new backend with the given name and constructor.
- Parameters:
name (str) – Unique backend name.
constructor (Callable[[BackendConfig], QuantumBackendProtocol]) – Constructor function returning a backend instance.
capabilities (Capabilities) – Metadata describing backend features and limits.
overwrite (bool, optional) – Whether to overwrite an existing entry with the same name. Default is
False.
- Raises:
ValueError – If
nameis empty.KeyError – If the backend name already exists and
overwrite=False.
- Return type:
- class qmlhc.core.registry.Entry(name, constructor, capabilities)[source]#
Bases:
objectRepresents a registry entry describing a backend constructor and its metadata.
- Parameters:
name (str) – Human-readable backend name.
constructor (Callable[[BackendConfig], QuantumBackendProtocol]) – Callable that returns an initialized backend instance when given a
BackendConfig.capabilities (Capabilities) – Static metadata describing backend capabilities.
-
capabilities:
Capabilities#
-
constructor:
Callable[[BackendConfig],QuantumBackend]#
- qmlhc.core.registry.create_backend(name, config)[source]#
Instantiate a registered backend by name.
- Parameters:
name (str) – Backend name.
config (BackendConfig) – Configuration for backend creation.
- Returns:
Instantiated backend object.
- Return type:
QuantumBackendProtocol
- qmlhc.core.registry.register_backend(name, constructor, capabilities, overwrite=False)[source]#
Register a backend globally.
- Parameters:
name (str) – Backend name.
constructor (Callable[[BackendConfig], QuantumBackendProtocol]) – Constructor function returning a backend instance.
capabilities (Capabilities) – Backend capabilities metadata.
overwrite (bool, optional) – Whether to overwrite an existing entry, by default
False.
- Return type: