/
GraphComparer.h
72 lines (52 loc) · 1.66 KB
/
GraphComparer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <string>
#include <list>
#include <map>
#include <memory>
#include "inode.h"
#include "imap.h"
#include "itextstream.h"
#include "ComparisonResult.h"
namespace scene
{
namespace merge
{
class GraphComparer
{
private:
scene::IMapRootNodePtr _source;
scene::IMapRootNodePtr _base;
ComparisonResult::Ptr _result;
using Fingerprints = std::map<std::string, scene::INodePtr>;
public:
struct EntityMismatch
{
std::string fingerPrint;
scene::INodePtr node;
std::string entityName;
};
using EntityMismatchByName = std::map<std::string, EntityMismatch>;
public:
GraphComparer(const scene::IMapRootNodePtr& source, const scene::IMapRootNodePtr& base) :
_source(source),
_base(base),
_result(new ComparisonResult(_source, _base))
{}
void compare();
const ComparisonResult::Ptr& getResult() const
{
return _result;
}
private:
void processDifferingEntities(const EntityMismatchByName& sourceMismatches, const EntityMismatchByName& baseMismatches);
Fingerprints collectEntityFingerprints(const scene::INodePtr& root);
Fingerprints collectPrimitiveFingerprints(const scene::INodePtr& parent);
Fingerprints collectNodeFingerprints(const scene::INodePtr& parent,
const std::function<bool(const scene::INodePtr& node)>& nodePredicate);
std::list<ComparisonResult::KeyValueDifference> compareKeyValues(
const scene::INodePtr& sourceNode, const scene::INodePtr& baseNode);
std::list<ComparisonResult::PrimitiveDifference> compareChildNodes(
const scene::INodePtr& sourceNode, const scene::INodePtr& baseNode);
};
}
}