MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Tapestry.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Fabric.hpp"
4
5namespace MayaFlux::Vruta {
6class TaskScheduler;
7class EventManager;
8}
9
10namespace MayaFlux::Nexus {
11
12/**
13 * @class Tapestry
14 * @brief Owner of one or more Fabrics and the shared state they rely on.
15 *
16 * A Tapestry holds shared_ptrs to the TaskScheduler and EventManager each
17 * Fabric needs, and serves as the authoring-surface layer above raw Fabric
18 * construction. Fabrics woven through a Tapestry can be looked up by name
19 * for state encoding, cross-fabric queries, and coordinated commits.
20 *
21 * Tapestry holds owning references to the scheduler and event manager so
22 * that every Fabric it create_fabrics is guaranteed a valid backing for the
23 * Tapestry's lifetime.
24 */
25class MAYAFLUX_API Tapestry {
26public:
27 /**
28 * @brief Construct with shared scheduler and event manager.
29 */
31 std::shared_ptr<Vruta::TaskScheduler> scheduler,
32 std::shared_ptr<Vruta::EventManager> event_manager);
33
35
36 Tapestry(const Tapestry&) = delete;
37 Tapestry& operator=(const Tapestry&) = delete;
38 Tapestry(Tapestry&&) = delete;
40
41 // =========================================================================
42 // Fabric lifecycle
43 // =========================================================================
44
45 /**
46 * @brief create_fabric a new unnamed Fabric into the Tapestry.
47 * @param cell_size Grid cell edge length for the spatial index.
48 */
49 [[nodiscard]] std::shared_ptr<Fabric> create_fabric(float cell_size = 1.0F);
50
51 /**
52 * @brief create_fabric a new named Fabric into the Tapestry.
53 * @param name Identifier for lookup; must not collide with existing names.
54 * @param cell_size Grid cell edge length for the spatial index.
55 */
56 [[nodiscard]] std::shared_ptr<Fabric> create_fabric(std::string name, float cell_size = 1.0F);
57
58 /**
59 * @brief Remove a Fabric by pointer. No-op if not owned by this Tapestry.
60 */
61 void remove_fabric(const std::shared_ptr<Fabric>& fabric);
62
63 /**
64 * @brief Remove a Fabric by name. No-op if name is not registered.
65 */
66 void remove_fabric(std::string_view name);
67
68 /**
69 * @brief Look up a named Fabric.
70 * @return The Fabric, or nullptr if name is not registered.
71 */
72 [[nodiscard]] std::shared_ptr<Fabric> get_fabric(std::string_view name) const;
73
74 /**
75 * @brief All woven Fabrics, named and unnamed.
76 */
77 [[nodiscard]] const std::vector<std::shared_ptr<Fabric>>& all_fabrics() const;
78
79 // =========================================================================
80 // Commit
81 // =========================================================================
82
83 /**
84 * @brief Commit all woven Fabrics in insertion order.
85 */
86 void commit_all();
87
88private:
89 std::shared_ptr<Vruta::TaskScheduler> m_scheduler;
90 std::shared_ptr<Vruta::EventManager> m_event_manager;
91
92 std::vector<std::shared_ptr<Fabric>> m_fabrics;
93 std::unordered_map<std::string, std::weak_ptr<Fabric>> m_named_fabrics;
94};
95
96} // namespace MayaFlux::Nexus
std::vector< std::shared_ptr< Fabric > > m_fabrics
Definition Tapestry.hpp:92
Tapestry & operator=(Tapestry &&)=delete
Tapestry & operator=(const Tapestry &)=delete
std::shared_ptr< Vruta::EventManager > m_event_manager
Definition Tapestry.hpp:90
std::shared_ptr< Vruta::TaskScheduler > m_scheduler
Definition Tapestry.hpp:89
Tapestry(Tapestry &&)=delete
std::unordered_map< std::string, std::weak_ptr< Fabric > > m_named_fabrics
Definition Tapestry.hpp:93
Tapestry(const Tapestry &)=delete
Owner of one or more Fabrics and the shared state they rely on.
Definition Tapestry.hpp:25