MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Stagecraft.hpp
Go to the documentation of this file.
1#pragma once
2
4
5/**
6 * @file API/Stagecraft.hpp
7 * @brief Nexus objects that need the engine's managers, built with them already supplied.
8 *
9 * Fabric and Tapestry take the scheduler, event manager and buffer manager as
10 * explicit arguments. These functions pass the default engine's. Everything
11 * else in Nexus takes no manager and is constructed directly.
12 *
13 * A Fabric keeps references to the engine's managers, so release it before
14 * MayaFlux::End(), or hand it to store() to have the persistent store do so.
15 */
16
17namespace MayaFlux {
18
19namespace Core {
20 class Window;
21}
22
23namespace Nexus {
24 class Fabric;
25 class Tapestry;
26}
27
29 struct RenderConfig;
30}
31
32/**
33 * @brief Construct a named Fabric over the default engine's managers.
34 * @param name Name used when the Fabric is encoded.
35 * @param cell_size Grid cell edge length for the spatial index.
36 *
37 * @code
38 * auto fabric = MayaFlux::create_fabric("main");
39 * fabric->wire(emitter).every(0.1).finalise();
40 * @endcode
41 */
42MAYAFLUX_API std::shared_ptr<Nexus::Fabric> create_fabric(const std::string& name, float cell_size = 1.0F);
43
44/**
45 * @brief Construct a Tapestry over the default engine's managers.
46 *
47 * Every Fabric the Tapestry creates is built over the same managers.
48 *
49 * @code
50 * auto tapestry = MayaFlux::create_tapestry();
51 * auto fabric = tapestry->create_fabric("main");
52 * @endcode
53 */
54MAYAFLUX_API std::shared_ptr<Nexus::Tapestry> create_tapestry();
55
56/**
57 * @brief Register an audio output for an Agent or Emitter on @p channel.
58 *
59 * Forwards to the entity's sink_audio with the engine's buffer manager.
60 * @p args are the optional producer function and name.
61 */
62template <typename Entity, typename... Args>
63 requires requires(Entity& entity, Buffers::BufferManager& manager, uint32_t channel, Args&&... args) {
64 entity.sink_audio(manager, channel, std::forward<Args>(args)...);
65 }
66void sink_audio(const std::shared_ptr<Entity>& entity, uint32_t channel, Args&&... args)
67{
68 entity->sink_audio(*get_buffer_manager(), channel, std::forward<Args>(args)...);
69}
70
71/**
72 * @brief Register a render output for an Agent or Emitter.
73 *
74 * Forwards to the entity's render with the engine's buffer manager.
75 * @p args are the optional name and producer function.
76 */
77template <typename Entity, typename... Args>
78 requires requires(Entity& entity, Buffers::BufferManager& manager, const Portal::Graphics::RenderConfig& config, Args&&... args) {
79 entity.render(manager, config, std::forward<Args>(args)...);
80 }
81void sink_render(const std::shared_ptr<Entity>& entity, const Portal::Graphics::RenderConfig& config, Args&&... args)
82{
83 entity->render(*get_buffer_manager(), config, std::forward<Args>(args)...);
84}
85
86/**
87 * @brief Unregister the audio output of an Agent or Emitter on @p channel.
88 *
89 * Needed only for an entity outside a Fabric; a Fabric releases the sinks of
90 * the entities it removes.
91 */
92template <typename Entity>
93 requires requires(Entity& entity, Buffers::BufferManager& manager, uint32_t channel) {
94 entity.remove_audio_sink(manager, channel);
95 }
96void remove_audio_sink(const std::shared_ptr<Entity>& entity, uint32_t channel)
97{
98 entity->remove_audio_sink(*get_buffer_manager(), channel);
99}
100
101/**
102 * @brief Unregister the render output of an Agent or Emitter targeting @p window.
103 *
104 * Needed only for an entity outside a Fabric.
105 */
106template <typename Entity>
107 requires requires(Entity& entity, Buffers::BufferManager& manager, const std::shared_ptr<Core::Window>& window) {
108 entity.remove_render(manager, window);
109 }
110void remove_render_sink(const std::shared_ptr<Entity>& entity, const std::shared_ptr<Core::Window>& window)
111{
112 entity->remove_render(*get_buffer_manager(), window);
113}
114
115} // namespace MayaFlux
Token-based multimodal buffer management system for unified data stream processing.
Platform-agnostic window wrapper.
Definition Window.hpp:27
Orchestrates spatial indexing and scheduling for Nexus objects.
Definition Fabric.hpp:42
Owner of one or more Fabrics and the shared state they rely on.
Definition Tapestry.hpp:25
void sink_audio(const std::shared_ptr< Entity > &entity, uint32_t channel, Args &&... args)
Register an audio output for an Agent or Emitter on channel.
void remove_audio_sink(const std::shared_ptr< Entity > &entity, uint32_t channel)
Unregister the audio output of an Agent or Emitter on channel.
void remove_render_sink(const std::shared_ptr< Entity > &entity, const std::shared_ptr< Core::Window > &window)
Unregister the render output of an Agent or Emitter targeting window.
std::shared_ptr< Nexus::Fabric > create_fabric(const std::string &name, float cell_size)
Construct a named Fabric over the default engine's managers.
void sink_render(const std::shared_ptr< Entity > &entity, const Portal::Graphics::RenderConfig &config, Args &&... args)
Register a render output for an Agent or Emitter.
std::shared_ptr< Buffers::BufferManager > get_buffer_manager()
Gets the buffer manager from the default engine.
Definition Graph.cpp:148
std::shared_ptr< Nexus::Tapestry > create_tapestry()
Construct a Tapestry over the default engine's managers.
Main namespace for the Maya Flux audio engine.
Unified rendering configuration for graphics buffers.