KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_merge_engine.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 */
20
21#ifndef KICAD_MERGE_ENGINE_H
22#define KICAD_MERGE_ENGINE_H
23
24#include <kicommon.h>
25
27
28#include <nlohmann/json_fwd.hpp>
29
30#include <string>
31#include <vector>
32
33
34namespace KICAD_DIFF
35{
36
52
53
72
73
78KICOMMON_API const char* ItemResToString( ITEM_RES aRes );
79KICOMMON_API ITEM_RES ItemResFromString( const std::string& aStr );
80
81
86KICOMMON_API const char* PropResToString( PROP_RES aRes );
87KICOMMON_API PROP_RES PropResFromString( const std::string& aStr );
88
89
91{
92 wxString name;
94 DIFF_VALUE customValue; // populated only when kind == CUSTOM
95
96 bool operator==( const PROPERTY_RESOLUTION& aOther ) const;
97 nlohmann::json ToJson() const;
98 static PROPERTY_RESOLUTION FromJson( const nlohmann::json& aJson );
99};
100
101
103{
106 std::vector<PROPERTY_RESOLUTION> props;
107
108 bool operator==( const ITEM_RESOLUTION& aOther ) const;
109 nlohmann::json ToJson() const;
110 static ITEM_RESOLUTION FromJson( const nlohmann::json& aJson );
111};
112
113
122{
123 std::vector<ITEM_RESOLUTION> actions;
124 std::vector<KIID_PATH> unresolved;
125 bool requiresZoneRefill = false;
127
128 bool Resolved() const { return unresolved.empty(); }
129 std::size_t ConflictCount() const { return unresolved.size(); }
130
131 nlohmann::json ToJson() const;
132 static MERGE_PLAN FromJson( const nlohmann::json& aJson );
133};
134
135
149{
150public:
151 struct OPTIONS
152 {
155 bool preferAutoMerge = true;
156
160 };
161
163 explicit KICAD_MERGE_ENGINE( const OPTIONS& aOptions ) : m_options( aOptions ) {}
164
165 const OPTIONS& GetOptions() const { return m_options; }
166 void SetOptions( const OPTIONS& aOptions ) { m_options = aOptions; }
167
174 MERGE_PLAN Plan( const DOCUMENT_DIFF& aAncestorOurs,
175 const DOCUMENT_DIFF& aAncestorTheirs ) const;
176
177private:
179};
180
181
195
196
224ResolvePropertyConflict( const PROPERTY_DELTA* aOurs, const PROPERTY_DELTA* aTheirs,
225 const KICAD_MERGE_ENGINE::OPTIONS& aOptions );
226
227} // namespace KICAD_DIFF
228
229#endif // KICAD_MERGE_ENGINE_H
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
A typed sum value used to carry the before/after of any single property.
const OPTIONS & GetOptions() const
void SetOptions(const OPTIONS &aOptions)
KICAD_MERGE_ENGINE(const OPTIONS &aOptions)
#define KICOMMON_API
Definition kicommon.h:27
ITEM_RES
Resolution kind for a whole item.
const char * PropResToString(PROP_RES aRes)
Canonical lower-case spellings for PROP_RES used inside the JSON serialization of PROPERTY_RESOLUTION...
PROP_RES PropResFromString(const std::string &aStr)
PROPERTY_RESOLUTION_OUTCOME ResolvePropertyConflict(const PROPERTY_DELTA *aOurs, const PROPERTY_DELTA *aTheirs, const KICAD_MERGE_ENGINE::OPTIONS &aOptions)
Decide how to resolve a single property edit between two sides.
ITEM_RES ItemResFromString(const std::string &aStr)
PROP_RES
Resolution kind for a single property of a single item.
const char * ItemResToString(ITEM_RES aRes)
Canonical snake_case spellings used in MERGE_PLAN JSON serialization (take_ours / take_theirs / take_...
The full set of changes between two parsed documents of one type.
std::vector< PROPERTY_RESOLUTION > props
static ITEM_RESOLUTION FromJson(const nlohmann::json &aJson)
bool preferAutoMerge
When true, property-orthogonal edits auto-merge silently.
bool autoResolveEqualValues
When true and a property edit conflicts but the side values are equal, the resolution is automaticall...
Result of planning a 3-way merge.
std::size_t ConflictCount() const
std::vector< ITEM_RESOLUTION > actions
std::vector< KIID_PATH > unresolved
Single (name, before, after) triple for one mutated property on an item.
Per-property merge decision result.
static PROPERTY_RESOLUTION FromJson(const nlohmann::json &aJson)