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

◆ merge()

template<typename Source, typename Access = Reflect::RecordAccess<Source>>
bool MayaFlux::Portal::Forma::FactoryTable< Source, Access >::merge ( const FactoryTable< Source, Access > & other,
std::string_view prefix,
std::string & error,
bool replace = false )
inline

Add every factory of another table under a name prefix.

Parameters
prefixPrepended to each name; empty keeps the names.
errorReceives the first colliding name when false is returned.
replaceTrue to overwrite existing names instead of failing.
Returns
True on success. A failed merge leaves this table unchanged.

Definition at line 219 of file FactoryTable.hpp.

221 {
222 if (!m_factories.merge_prefixed(other.m_factories, prefix, error, replace))
223 return false;
224 for (const auto& entry : other.m_factories) {
225 const std::string target = std::string(prefix) + entry.first;
226 const auto bulk = other.m_bulk.find(entry.first);
227 if (bulk != other.m_bulk.end()) {
228 m_bulk.insert_or_assign(target, bulk->second);
229 } else {
230 m_bulk.erase(target);
231 }
232 }
233 return true;
234 }
const_iterator end() const noexcept
Definition FlatMap.hpp:27
const_iterator find(const K &key) const
The entry for key, or end() when absent.
Definition FlatMap.hpp:32
Memory::FlatMap< std::string, BulkInstantiator, std::less<> > m_bulk
Memory::FlatMap< std::string, Instantiator, std::less<> > m_factories
Named factories that turn a template's factory element and an instance into placed Forma elements,...