1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_
6 #define COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_
7 
8 #include <ostream>
9 
10 #include "components/zucchini/buffer_view.h"
11 #include "components/zucchini/ensemble_matcher.h"
12 
13 namespace zucchini {
14 
15 // An ensemble matcher that:
16 // - Detects embedded elements in "old" and "new" archive files.
17 // - Applies heuristics to create matched pairs.
18 // It is desired to have matched pairs that:
19 // - Have "reasonable" size difference (see UnsafeDifference() in the .cc file).
20 // - Have "minimal distance" among other potential matched pairs.
21 class HeuristicEnsembleMatcher : public EnsembleMatcher {
22  public:
23   explicit HeuristicEnsembleMatcher(std::ostream* out);
24   HeuristicEnsembleMatcher(const HeuristicEnsembleMatcher&) = delete;
25   const HeuristicEnsembleMatcher& operator=(const HeuristicEnsembleMatcher&) =
26       delete;
27   ~HeuristicEnsembleMatcher() override;
28 
29   // EnsembleMatcher:
30   bool RunMatch(ConstBufferView old_image, ConstBufferView new_image) override;
31 
32  private:
33   // Optional stream to print detailed information during matching.
34   std::ostream* out_ = nullptr;
35 };
36 
37 }  // namespace zucchini
38 
39 #endif  // COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_
40