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