MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ remove()

bool MayaFlux::Portal::Forma::Layer::remove ( uint32_t  id)

Remove an element by id, cascading to every related id.

Marks each removed element's buffer for removal.

Returns
True if id was found.

Definition at line 17 of file Layer.cpp.

18{
19 if (!get(id))
20 return false;
21
22 const std::vector<uint32_t> ids = closure(id);
23
24 for (uint32_t cid : ids) {
25 if (auto* el = get(cid); el && el->buffer)
26 el->buffer.retire();
27 std::erase_if(m_elements, [cid](const Element& e) { return e.id == cid; });
28 m_index_stale = true;
29 }
30
31 for (uint32_t cid : ids)
32 m_relations.erase(cid);
33
34 for (auto& [primary_id, related] : m_relations) {
35 for (uint32_t cid : ids)
36 std::erase(related, cid);
37 }
38 std::erase_if(m_relations, [](const auto& kv) { return kv.second.empty(); });
39
40 return true;
41}
std::vector< uint64_t > ids
std::vector< uint32_t > closure(uint32_t id) const
Return id plus every id transitively related to it.
Definition Layer.cpp:243
const Element * get(uint32_t id) const
Definition Layer.cpp:272
std::vector< Element > m_elements
Definition Layer.hpp:313
std::unordered_map< uint32_t, std::vector< uint32_t > > m_relations
Definition Layer.hpp:321
void erase(EditableText &s, int n)
Erase n codepoints from the cursor.
Definition TextEdit.cpp:31
FormaTarget buffer
Where this region's rendered output is written: a buffer of its own, or a slice of one it shares.
Definition Element.hpp:82

References MayaFlux::Portal::Forma::Element::buffer, closure(), get(), MayaFlux::Portal::Forma::Element::id, ids, m_elements, m_index_stale, and m_relations.

Referenced by MayaFlux::Portal::Forma::destroy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: