|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Named factories that turn a template's factory element and an instance into placed Forma elements, as a plain value. More...
#include <FactoryTable.hpp>
Public Types | |
| using | BulkInstantiator |
| Decodes a factory element and typed placement rows into one Placer per row. | |
| using | Instantiator |
| Decodes a factory element and an instance into a Placer, or nullopt with an error. | |
| using | Placer = std::function<std::optional<uint32_t>(Surface&, std::string&)> |
| Places one prepared element, or several, onto a Surface. | |
Public Member Functions | |
| bool | contains (std::string_view name) const |
| Whether a factory of this name is registered. | |
| void | expose_placement (std::string name, Instantiator instantiator) |
| Register a whole placement. | |
| template<typename T, Reflect::Described Input, Reflect::Described Placement, typename Factory, typename Initial> | |
| void | expose_typed (std::string name, Reflect::RecordBinding< Input, Source, Access > input, Reflect::RecordBinding< Placement, Source, Access > placement, Factory factory, Initial initial, std::type_identity_t< std::function< void(const Input &, const Placement &, Tend< T > &)> > placed={}) |
| Expose a factory whose inputs and placement are described types. | |
| const Instantiator * | find (std::string_view name) const |
| The factory of this name, or nullptr. | |
| const BulkInstantiator * | find_bulk (std::string_view name) const |
| The bulk path of this name, or nullptr when it was not registered with expose_typed. | |
| bool | merge (const FactoryTable &other, std::string_view prefix, std::string &error, bool replace=false) |
| Add every factory of another table under a name prefix. | |
| std::vector< std::string > | names () const |
| Registered names in sorted order. | |
Static Public Member Functions | |
| static std::string | located (uint64_t row, std::string_view message) |
| The message prefixed with the row it concerns. | |
Static Private Member Functions | |
| template<typename T> | |
| static Placer | make_placer (Geometry::Form< T > form, T initial, std::function< void(Tend< T > &)> after) |
Private Attributes | |
| Memory::FlatMap< std::string, BulkInstantiator, std::less<> > | m_bulk |
| Memory::FlatMap< std::string, Instantiator, std::less<> > | m_factories |
Named factories that turn a template's factory element and an instance into placed Forma elements, as a plain value.
A table is a plain value. It holds only what its builder registers, and nothing is pre-registered or privileged: a host, a library or a user each build their own and combine them with merge(). A factory is a preparation that decodes everything and returns a Placer, so a document can be checked completely before anything is placed.
Source is any element type with a Reflect::RecordAccess specialization and value semantics, so the same table serves XML, a script or any other document tree.
Two ways to register:
Errors name the row of the failing element.
Usage:
Definition at line 62 of file FactoryTable.hpp.