24#ifndef LIB_MERGE_APPLIER_H
25#define LIB_MERGE_APPLIER_H
57template <
typename ITEM>
61 using ITEM_MAP = std::map<wxString, const ITEM*>;
87 std::vector<std::unique_ptr<ITEM>>
Apply()
91 std::map<wxString, const ITEM*> live =
m_ancestor;
93 std::map<KIID_PATH, const ITEM_RESOLUTION*> actionsById;
96 actionsById[
res.id] = &
res;
100 for(
const wxString&
name : allNames )
104 if( resIt == actionsById.end() )
150 m_report.mergePropsFallbackIds.push_back(
res.id );
152 wxT(
"lib_merge_applier: MERGE_PROPS for '%s' fell back to "
159 std::vector<std::unique_ptr<ITEM>> out;
160 out.reserve( live.size() );
162 for(
const auto& [
name, item] : live )
165 out.emplace_back( std::make_unique<ITEM>( *item ) );
176 auto it = aMap.find( aName );
177 return it == aMap.end() ? nullptr : it->second;
182 std::set<wxString> out;
184 for(
const auto& [
name,
_] : aAncestor )
186 for(
const auto& [
name,
_] : aOurs )
188 for(
const auto& [
name,
_] : aTheirs )
194 static void takeFrom(
const ITEM_MAP& aSource,
const wxString& aName, std::map<wxString, const ITEM*>& aLive,
195 std::size_t& aCounter )
200 aLive.erase( aName );
static const ITEM * findItem(const ITEM_MAP &aMap, const wxString &aName)
const ITEM_MAP & m_theirs
static void takeFrom(const ITEM_MAP &aSource, const wxString &aName, std::map< wxString, const ITEM * > &aLive, std::size_t &aCounter)
const REPORT & GetReport() const
LIB_MERGE_APPLIER(const ITEM_MAP &aAncestor, const ITEM_MAP &aOurs, const ITEM_MAP &aTheirs, MERGE_PLAN aPlan)
std::map< wxString, const LIB_SYMBOL * > ITEM_MAP
std::vector< std::unique_ptr< ITEM > > Apply()
const ITEM_MAP & m_ancestor
static std::set< wxString > collectNames(const ITEM_MAP &aAncestor, const ITEM_MAP &aOurs, const ITEM_MAP &aTheirs)
const wxChar *const traceDiffMerge
Flag to enable diff/merge engine and renderer debugging output.
KIID_PATH LibraryItemKiidPath(const wxString &aName)
Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).
std::size_t mergePropsFallback
std::size_t itemsTakenOurs
std::size_t itemsTakenTheirs
std::size_t itemsTakenAncestor
std::vector< KIID_PATH > mergePropsFallbackIds
Item IDs (KIID_PATH from LibraryItemKiidPath) for resolutions that the applier silently downgraded (c...
Result of planning a 3-way merge.
wxLogTrace helper definitions.