MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Forma::ActionTable< Source, Access > Class Template Reference

Actions by name, which a document attaches to events and never defines. More...

#include <ActionTable.hpp>

Inheritance diagram for MayaFlux::Portal::Forma::ActionTable< Source, Access >:
Collaboration diagram for MayaFlux::Portal::Forma::ActionTable< Source, Access >:

Public Types

using Maker = std::function<std::optional<Action>(const Source&, std::string&)>
 Decodes an on element into the action to run, or nullopt with an error.

Public Member Functions

bool contains (std::string_view name) const
void expose (std::string name, Action action)
 Register an action that takes no parameters.
template<Reflect::Described Input>
void expose_typed (std::string name, Reflect::RecordBinding< Input, Source, Access > binding, std::type_identity_t< std::function< Action(const Input &)> > make)
 Register an action whose parameters are a described type.
const Maker * find (std::string_view name) const
 The maker of this name, or nullptr.
bool merge (const ActionTable &other, std::string_view prefix, std::string &error, bool replace=false)
 Add every action of another table under a name prefix.
std::vector< std::string > names () const
 Registered names in sorted order.

Private Attributes

Memory::FlatMap< std::string, Maker, std::less<> > m_makers

Detailed Description

template<typename Source, typename Access = Reflect::RecordAccess<Source>>
class MayaFlux::Portal::Forma::ActionTable< Source, Access >

Actions by name, which a document attaches to events and never defines.

A plain value like every table here. An instance of a document may hold on children, each naming a window event, the button or key it concerns and an action. The names are resolved when the document is checked, so an unknown action fails before anything is placed. An action may take parameters, written as further attributes of the on element and decoded strictly through a described type.

Because an action is subscribed beside an element's own wiring, it never replaces a Form's built in interaction.

Usage:

actions.expose_typed<PrintInputs>("print", {}, [](const PrintInputs& input) {
return Action([message = input.message](const ActionEvent&) { std::cout << message << '\n'; });
});
void expose_typed(std::string name, Reflect::RecordBinding< Input, Source, Access > binding, std::type_identity_t< std::function< Action(const Input &)> > make)
Register an action whose parameters are a described type.
Actions by name, which a document attaches to events and never defines.
std::function< void(const ActionEvent &)> Action
Code a host registers by name to run when an instance's event happens.
What an action is told when its event happens on an instance.
Template Parameters
SourceElement type with a Reflect::RecordAccess specialization.

Definition at line 58 of file ActionTable.hpp.


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