|
parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
|
Runtime catalog of cell-type descriptors, keyed by wire kind id. More...
#include <registry.h>
Public Member Functions | |
| ParcelRegistry (BuiltinsOptions opts={}) | |
| Construct, optionally tuning which builtins are pre-registered. | |
| void | register_kind (cell_type_descriptor_t d) |
| Register or replace a descriptor by its kind id. | |
| template<typename... Ds> | |
| ParcelRegistry & | register_kinds (Ds &&... ds) |
| Variadic shorthand: register many descriptors in one call. | |
| template<typename... Cs> | |
| ParcelRegistry & | register_cells () |
| Variadic shorthand: register one descriptor per cell type. | |
| cell_type_descriptor_t | find (std::string_view kind) const |
| Look up a descriptor by kind id. | |
| cell_t | cell_from_json (json_t const &j) const |
Deserialize any registered cell from JSON, dispatching by "k". | |
| std::vector< cell_type_descriptor_t > | all () const |
| Every registered descriptor. | |
| std::vector< std::string_view > | kinds () const |
| Every registered kind id. | |
| std::size_t | count () const noexcept |
| Number of registered kinds. | |
| bool | contains (std::string_view kind) const |
Whether kind is registered. | |
| std::vector< cell_type_descriptor_t > | find_by_category (descriptor::CellCategory c) const |
Every descriptor whose category() matches c. | |
| std::vector< cell_type_descriptor_t > | find_by_storage (std::type_index ti) const |
Every descriptor whose storage_type() matches ti. | |
| template<typename T > | |
| std::vector< cell_type_descriptor_t > | find_by_storage () const |
Every descriptor whose storage type is T. | |
| Definition | define (std::string_view kind) const |
Build a Definition rooted at kind plus everything it references. | |
Runtime catalog of cell-type descriptors, keyed by wire kind id.
Heterogeneous containers and any code deserializing from an arbitrary "k" go through the registry. The default-constructed registry calls register_builtins so the standard kinds are immediately available.
|
inlineexplicit |
Construct, optionally tuning which builtins are pre-registered.
| opts | Toggles forwarded to register_builtins. |
Deserialize any registered cell from JSON, dispatching by "k".
| j | Input JSON object — must contain a "k" matching a registered kind. |
| std::runtime_error | on shape mismatch or unknown kind. |
|
inline |
Whether kind is registered.
| kind | Wire kind id. |
|
inline |
Build a Definition rooted at kind plus everything it references.
| kind | Wire kind id of the root. |
Definition containing the root descriptor and every transitively referenced kind. | std::runtime_error | if kind is not registered, or if a referenced kind is missing from the registry. |
|
inline |
Look up a descriptor by kind id.
| kind | Wire kind id. |
nullptr if not registered.
|
inline |
Every descriptor whose category() matches c.
| c | Category filter. |
|
inline |
Every descriptor whose storage type is T.
| T | Storage type to match. |
|
inline |
Every descriptor whose storage_type() matches ti.
| ti | Storage std::type_index filter. |
|
inline |
Variadic shorthand: register one descriptor per cell type.
| Cs | Pack of CellLike types whose descriptor() is registered. |
*this for chaining.
|
inline |
Register or replace a descriptor by its kind id.
| d | Descriptor to register; must be non-null. |
| std::runtime_error | if d is null. |
|
inline |
Variadic shorthand: register many descriptors in one call.
| Ds | Pack of descriptor types convertible to cell_type_descriptor_t. |
| ds | Descriptors to register. |
*this for chaining.