heuristic_ensemble_matcher.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #ifndef COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_
  5. #define COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_
  6. #include <ostream>
  7. #include "base/memory/raw_ptr.h"
  8. #include "components/zucchini/buffer_view.h"
  9. #include "components/zucchini/ensemble_matcher.h"
  10. namespace zucchini {
  11. // An ensemble matcher that:
  12. // - Detects embedded elements in "old" and "new" archive files.
  13. // - Applies heuristics to create matched pairs.
  14. // It is desired to have matched pairs that:
  15. // - Have "reasonable" size difference (see UnsafeDifference() in the .cc file).
  16. // - Have "minimal distance" among other potential matched pairs.
  17. class HeuristicEnsembleMatcher : public EnsembleMatcher {
  18. public:
  19. explicit HeuristicEnsembleMatcher(std::ostream* out);
  20. HeuristicEnsembleMatcher(const HeuristicEnsembleMatcher&) = delete;
  21. const HeuristicEnsembleMatcher& operator=(const HeuristicEnsembleMatcher&) =
  22. delete;
  23. ~HeuristicEnsembleMatcher() override;
  24. // EnsembleMatcher:
  25. bool RunMatch(ConstBufferView old_image, ConstBufferView new_image) override;
  26. private:
  27. // Optional stream to print detailed information during matching.
  28. raw_ptr<std::ostream> out_ = nullptr;
  29. };
  30. } // namespace zucchini
  31. #endif // COMPONENTS_ZUCCHINI_HEURISTIC_ENSEMBLE_MATCHER_H_