MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Link.hpp
Go to the documentation of this file.
1#pragma once
2
4
5/**
6 * @brief A directed coupling between Forma participants.
7 *
8 * A Link has two distinct moments:
9 *
10 * establish - runs once at construction. This is where the coupling is
11 * formed: attaching a processor to a buffer, setting initial state,
12 * registering a relation. For some links this is the entire effect.
13 *
14 * activate - the repeatable body of the coupling. Closed over whatever
15 * source and target participants are relevant. Expresses the full
16 * transfer: read, transform, apply, any gating. When the link has no
17 * repeatable behavior, activate is []{}. It is always callable.
18 *
19 * Who calls activate and when is entirely the caller's concern. A Context
20 * callback, a version-gating wrapper, a Lila script, another Link's
21 * activate body - all are valid drivers.
22 */
23struct Link {
24 std::function<void()> establish;
25 std::function<void()> tap { [] { } };
26
27 /**
28 * @brief Construct and immediately run establish.
29 * @param est Coupling formation function. Run once here.
30 * @param t Repeatable tap body. Defaults to no-op.
31 */
32 Link(std::function<void()> est, std::function<void()> t = [] { })
33 : establish(std::move(est))
34 , tap(std::move(t))
35 {
36 if (establish)
37 establish();
38 }
39
40 Link(Link&&) noexcept = default;
41 Link& operator=(Link&&) noexcept = default;
42 Link(const Link&) = delete;
43 Link& operator=(const Link&) = delete;
44};
45
46} // namespace MayaFlux::Portal::Forma