From 3cb22a7fdca2db39321c4eeafd63c12206039411 Mon Sep 17 00:00:00 2001 From: Taku Kudo Date: Tue, 24 Dec 2024 09:11:01 +0000 Subject: [PATCH] Remove DataManagerInterface because it is introduced only for testing (mock), not polymorphism. PiperOrigin-RevId: 709273265 --- src/converter/BUILD.bazel | 6 +- src/converter/connector.cc | 4 +- src/converter/connector.h | 4 +- src/converter/converter_test.cc | 6 +- src/converter/segmenter.cc | 4 +- src/converter/segmenter.h | 4 +- src/data_manager/BUILD.bazel | 12 +- src/data_manager/data_manager.h | 71 ++++---- src/data_manager/data_manager_interface.h | 165 ------------------ src/data_manager/data_manager_test_base.cc | 4 +- src/data_manager/data_manager_test_base.h | 6 +- src/dictionary/BUILD.bazel | 4 +- src/dictionary/single_kanji_dictionary.cc | 5 +- src/dictionary/single_kanji_dictionary.h | 4 +- src/dictionary/user_pos.cc | 4 +- src/dictionary/user_pos.h | 4 +- src/engine/BUILD.bazel | 5 +- src/engine/data_loader_test.cc | 3 +- src/engine/engine.cc | 6 +- src/engine/engine.h | 6 +- src/engine/modules.cc | 5 +- src/engine/modules.h | 8 +- src/prediction/BUILD.bazel | 4 +- .../dictionary_prediction_aggregator_test.cc | 5 +- .../single_kanji_prediction_aggregator.cc | 4 +- .../single_kanji_prediction_aggregator.h | 5 +- src/rewriter/BUILD.bazel | 26 +-- src/rewriter/a11y_description_rewriter.cc | 4 +- src/rewriter/a11y_description_rewriter.h | 4 +- src/rewriter/collocation_rewriter.cc | 4 +- src/rewriter/collocation_rewriter.h | 4 +- src/rewriter/correction_rewriter.cc | 4 +- src/rewriter/correction_rewriter.h | 4 +- src/rewriter/dictionary_generator.cc | 4 +- src/rewriter/dictionary_generator.h | 4 +- src/rewriter/emoji_rewriter.cc | 4 +- src/rewriter/emoji_rewriter.h | 4 +- src/rewriter/emoticon_rewriter.cc | 4 +- src/rewriter/emoticon_rewriter.h | 4 +- src/rewriter/environmental_filter_rewriter.cc | 4 +- src/rewriter/environmental_filter_rewriter.h | 4 +- src/rewriter/focus_candidate_rewriter.cc | 4 +- src/rewriter/focus_candidate_rewriter.h | 4 +- src/rewriter/number_compound_util.h | 2 +- src/rewriter/number_rewriter.cc | 4 +- src/rewriter/number_rewriter.h | 4 +- src/rewriter/rewriter.cc | 4 +- src/rewriter/single_kanji_rewriter.cc | 4 +- src/rewriter/single_kanji_rewriter.h | 4 +- src/rewriter/symbol_rewriter.cc | 4 +- src/rewriter/symbol_rewriter.h | 4 +- src/rewriter/usage_rewriter.cc | 4 +- src/rewriter/usage_rewriter.h | 4 +- src/session/BUILD.bazel | 4 +- src/session/session_handler_main.cc | 2 +- 55 files changed, 155 insertions(+), 337 deletions(-) delete mode 100644 src/data_manager/data_manager_interface.h diff --git a/src/converter/BUILD.bazel b/src/converter/BUILD.bazel index 61a1b0967..bc9cc52fa 100644 --- a/src/converter/BUILD.bazel +++ b/src/converter/BUILD.bazel @@ -140,7 +140,7 @@ mozc_cc_library( srcs = ["connector.cc"], hdrs = ["connector.h"], deps = [ - "//data_manager:data_manager_interface", + "//data_manager", "//storage/louds:simple_succinct_bit_vector_index", "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/base:core_headers", @@ -280,7 +280,7 @@ mozc_cc_library( deps = [ ":node", "//base/container:bitarray", - "//data_manager:data_manager_interface", + "//data_manager", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", ], @@ -465,7 +465,7 @@ mozc_cc_test( "//composer", "//composer:table", "//config:config_handler", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager/testing:mock_data_manager", "//dictionary:dictionary_interface", "//dictionary:dictionary_mock", diff --git a/src/converter/connector.cc b/src/converter/connector.cc index 35b088c70..7be6ff098 100644 --- a/src/converter/connector.cc +++ b/src/converter/connector.cc @@ -46,7 +46,7 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "storage/louds/simple_succinct_bit_vector_index.h" @@ -173,7 +173,7 @@ std::optional Connector::Row::GetValue(uint16_t index) const { } absl::StatusOr Connector::CreateFromDataManager( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { #ifdef __ANDROID__ constexpr int kCacheSize = 256; #else // __ANDROID__ diff --git a/src/converter/connector.h b/src/converter/connector.h index 8ed8af06e..32eff17ea 100644 --- a/src/converter/connector.h +++ b/src/converter/connector.h @@ -37,7 +37,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "storage/louds/simple_succinct_bit_vector_index.h" namespace mozc { @@ -47,7 +47,7 @@ class Connector final { static constexpr int16_t kInvalidCost = 30000; static absl::StatusOr CreateFromDataManager( - const DataManagerInterface &data_manager); + const DataManager &data_manager); static absl::StatusOr Create(absl::string_view connection_data, int cache_size); diff --git a/src/converter/converter_test.cc b/src/converter/converter_test.cc index cb846e756..ec651285f 100644 --- a/src/converter/converter_test.cc +++ b/src/converter/converter_test.cc @@ -56,7 +56,7 @@ #include "converter/immutable_converter_interface.h" #include "converter/segments.h" #include "converter/segments_matchers.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/testing/mock_data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/dictionary_mock.h" @@ -193,8 +193,8 @@ class ResizeSegmentsRewriter : public RewriterInterface { } RewriterInterface::ResizeSegmentsRequest resize_request = { - .segment_index = segment_index_, - .segment_sizes = segment_sizes_, + .segment_index = segment_index_, + .segment_sizes = segment_sizes_, }; return resize_request; } diff --git a/src/converter/segmenter.cc b/src/converter/segmenter.cc index 66ed3eda6..e0c4d855f 100644 --- a/src/converter/segmenter.cc +++ b/src/converter/segmenter.cc @@ -37,12 +37,12 @@ #include "absl/types/span.h" #include "base/container/bitarray.h" #include "converter/node.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" namespace mozc { std::unique_ptr Segmenter::CreateFromDataManager( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { size_t l_num_elements = 0; size_t r_num_elements = 0; absl::Span l_table, r_table, boundary_data; diff --git a/src/converter/segmenter.h b/src/converter/segmenter.h index 6c98d42d2..33ec3e80b 100644 --- a/src/converter/segmenter.h +++ b/src/converter/segmenter.h @@ -35,14 +35,14 @@ #include #include "converter/node.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" namespace mozc { class Segmenter { public: static std::unique_ptr CreateFromDataManager( - const DataManagerInterface &data_manager); + const DataManager &data_manager); // This class does not take the ownership of pointer parameters. Segmenter(size_t l_num_elements, size_t r_num_elements, diff --git a/src/data_manager/BUILD.bazel b/src/data_manager/BUILD.bazel index c8fd8daac..991dfdcb4 100644 --- a/src/data_manager/BUILD.bazel +++ b/src/data_manager/BUILD.bazel @@ -42,15 +42,6 @@ load("//bazel:stubs.bzl", "bzl_library") package(default_visibility = ["//visibility:public"]) -mozc_cc_library( - name = "data_manager_interface", - hdrs = ["data_manager_interface.h"], - deps = [ - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:span", - ], -) - mozc_cc_library( name = "data_manager", srcs = [ @@ -58,7 +49,6 @@ mozc_cc_library( ], hdrs = ["data_manager.h"], deps = [ - ":data_manager_interface", ":dataset_reader", ":serialized_dictionary", "//base:mmap", @@ -85,7 +75,7 @@ mozc_cc_library( hdrs = ["data_manager_test_base.h"], deps = [ ":connection_file_reader", - ":data_manager_interface", + ":data_manager", "//base:file_stream", "//base:util", "//base/container:serialized_string_array", diff --git a/src/data_manager/data_manager.h b/src/data_manager/data_manager.h index 344ea027a..a182d2356 100644 --- a/src/data_manager/data_manager.h +++ b/src/data_manager/data_manager.h @@ -44,7 +44,6 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "base/mmap.h" -#include "data_manager/data_manager_interface.h" namespace mozc { @@ -54,7 +53,7 @@ class DataSetReader; // Forward-declare this as it is used privately. // (dictionary, LM, etc.). // TODO(noriyukit): Migrate all the embedded data managers, such as // oss/oss_data_manager.h, to this one. -class DataManager : public DataManagerInterface { +class DataManager { public: // Return status for initialization. enum class Status { @@ -79,6 +78,7 @@ class DataManager : public DataManagerInterface { DataManager() = default; DataManager(const DataManager &) = delete; DataManager &operator=(const DataManager &) = delete; + virtual ~DataManager() = default; // Parses |array| and extracts byte blocks of data set. The |array| must // outlive this instance. The second version specifies a custom magic number @@ -104,66 +104,65 @@ class DataManager : public DataManagerInterface { absl::string_view magic); // Implementation of DataManagerInterface. - std::optional GetFilename() const override { return filename_; } - absl::Span GetPosMatcherData() const override; - void GetUserPosData(absl::string_view *token_array_data, - absl::string_view *string_array_data) const override; - absl::string_view GetConnectorData() const override; - absl::string_view GetSystemDictionaryData() const override; - absl::Span GetCollocationData() const override; - absl::Span GetCollocationSuppressionData() const override; - absl::Span GetSuggestionFilterData() const override; - absl::Span GetPosGroupData() const override; - void GetSegmenterData( + virtual std::optional GetFilename() const { return filename_; } + virtual absl::Span GetPosMatcherData() const; + virtual void GetUserPosData(absl::string_view *token_array_data, + absl::string_view *string_array_data) const; + virtual absl::string_view GetConnectorData() const; + virtual absl::string_view GetSystemDictionaryData() const; + virtual absl::Span GetCollocationData() const; + virtual absl::Span GetCollocationSuppressionData() const; + virtual absl::Span GetSuggestionFilterData() const; + virtual absl::Span GetPosGroupData() const; + virtual void GetSegmenterData( size_t *l_num_elements, size_t *r_num_elements, absl::Span *l_table, absl::Span *r_table, absl::Span *bitarray_data, - absl::Span *boundary_data) const override; + absl::Span *boundary_data) const; absl::string_view GetCounterSuffixSortedArray() const; - void GetSuffixDictionaryData( + virtual void GetSuffixDictionaryData( absl::string_view *key_array, absl::string_view *value_array, - absl::Span *token_array) const override; - void GetReadingCorrectionData( + absl::Span *token_array) const; + virtual void GetReadingCorrectionData( absl::string_view *value_array_data, absl::string_view *error_array_data, - absl::string_view *correction_array_data) const override; - void GetSymbolRewriterData( + absl::string_view *correction_array_data) const; + virtual void GetSymbolRewriterData( absl::string_view *token_array_data, - absl::string_view *string_array_data) const override; - void GetEmoticonRewriterData( + absl::string_view *string_array_data) const; + virtual void GetEmoticonRewriterData( absl::string_view *token_array_data, - absl::string_view *string_array_data) const override; - void GetEmojiRewriterData( - absl::string_view *token_array_data, - absl::string_view *string_array_data) const override; - void GetSingleKanjiRewriterData( + absl::string_view *string_array_data) const; + virtual void GetEmojiRewriterData(absl::string_view *token_array_data, + absl::string_view *string_array_data) const; + virtual void GetSingleKanjiRewriterData( absl::string_view *token_array_data, absl::string_view *string_array_data, absl::string_view *variant_type_array_data, absl::string_view *variant_token_array_data, absl::string_view *variant_string_array_data, absl::string_view *noun_prefix_token_array_data, - absl::string_view *noun_prefix_string_array_data) const override; - void GetA11yDescriptionRewriterData( + absl::string_view *noun_prefix_string_array_data) const; + virtual void GetA11yDescriptionRewriterData( absl::string_view *token_array_data, - absl::string_view *string_array_data) const override; - void GetZeroQueryData( + absl::string_view *string_array_data) const; + virtual void GetZeroQueryData( absl::string_view *zero_query_token_array_data, absl::string_view *zero_query_string_array_data, absl::string_view *zero_query_number_token_array_data, - absl::string_view *zero_query_number_string_array_data) const override; + absl::string_view *zero_query_number_string_array_data) const; #ifndef NO_USAGE_REWRITER - void GetUsageRewriterData( + virtual void GetUsageRewriterData( absl::string_view *base_conjugation_suffix_data, absl::string_view *conjugation_suffix_data, absl::string_view *conjugation_index_data, absl::string_view *usage_items_data, - absl::string_view *string_array_data) const override; + absl::string_view *string_array_data) const; #endif // NO_USAGE_REWRITER - absl::string_view GetDataVersion() const override; + virtual absl::string_view GetDataVersion() const; - std::optional> GetOffsetAndSize( - absl::string_view name) const override; + virtual std::optional> GetOffsetAndSize( + absl::string_view name) const; private: Status InitFromReader(const DataSetReader &reader); diff --git a/src/data_manager/data_manager_interface.h b/src/data_manager/data_manager_interface.h deleted file mode 100644 index 093a8b147..000000000 --- a/src/data_manager/data_manager_interface.h +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2010-2021, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef MOZC_DATA_MANAGER_DATA_MANAGER_INTERFACE_H_ -#define MOZC_DATA_MANAGER_DATA_MANAGER_INTERFACE_H_ - -#include -#include -#include -#include -#include - -#include "absl/strings/string_view.h" -#include "absl/types/span.h" - -namespace mozc { - -// Builds those objects that depend on a set of embedded data generated from -// files in data/dictionary, such as dictionary.txt, id.def, etc. -class DataManagerInterface { - public: - DataManagerInterface(const DataManagerInterface &) = delete; - DataManagerInterface &operator=(const DataManagerInterface &) = delete; - virtual ~DataManagerInterface() = default; - - // Returns the file name from which the data manager is loaded. This may be - // nullopt if it is loaded from memory blob. - virtual std::optional GetFilename() const { - return std::nullopt; - } - - // Returns data set for UserPos. - virtual void GetUserPosData(absl::string_view *token_array_data, - absl::string_view *string_array_data) const = 0; - - // Returns a reference to PosMatcher class handling POS rules. Don't - // delete the returned pointer, which is owned by the manager. - virtual absl::Span GetPosMatcherData() const = 0; - - // Returns the address of an array of lid group. - virtual absl::Span GetPosGroupData() const = 0; - - // Returns the address of connection data and its size. - virtual absl::string_view GetConnectorData() const = 0; - - // Returns the addresses and their sizes necessary to create a segmenter. - virtual void GetSegmenterData( - size_t *l_num_elements, size_t *r_num_elements, - absl::Span *l_table, absl::Span *r_table, - absl::Span *bitarray_data, - absl::Span *boundary_data) const = 0; - - // Returns the address of system dictionary data and its size. - virtual absl::string_view GetSystemDictionaryData() const = 0; - - // Returns the array containing keys, values, and token (lid, rid, cost). - virtual void GetSuffixDictionaryData( - absl::string_view *key_array, absl::string_view *value_array, - absl::Span *token_array) const = 0; - - // Gets a reference to reading correction data array and its size. - virtual void GetReadingCorrectionData( - absl::string_view *value_array_data, absl::string_view *error_array_data, - absl::string_view *correction_array_data) const = 0; - - // Gets the address of collocation data array and its size. - virtual absl::Span GetCollocationData() const = 0; - - // Gets the address of collocation suppression data array and its size. - virtual absl::Span GetCollocationSuppressionData() const = 0; - - // Gets an address of suggestion filter data array and its size. - virtual absl::Span GetSuggestionFilterData() const = 0; - - // Gets an address of symbol rewriter data array and its size. - virtual void GetSymbolRewriterData( - absl::string_view *token_array_data, - absl::string_view *string_array_data) const = 0; - - // Gets an address of symbol rewriter data array and its size. - virtual void GetEmoticonRewriterData( - absl::string_view *token_array_data, - absl::string_view *string_array_data) const = 0; - - // Gets EmojiRewriter data. - virtual void GetEmojiRewriterData( - absl::string_view *token_array_data, - absl::string_view *string_array_data) const = 0; - - // Gets SingleKanjiRewriter data. - virtual void GetSingleKanjiRewriterData( - absl::string_view *token_array_data, absl::string_view *string_array_data, - absl::string_view *variant_type_array_data, - absl::string_view *variant_token_array_data, - absl::string_view *variant_string_array_data, - absl::string_view *noun_prefix_token_array_data, - absl::string_view *noun_prefix_string_array_data) const = 0; - - // Gets A11yDescriptionRewriter data. - virtual void GetA11yDescriptionRewriterData( - absl::string_view *token_array_data, - absl::string_view *string_array_data) const = 0; - -#ifndef NO_USAGE_REWRITER - // Gets the usage rewriter data. - virtual void GetUsageRewriterData( - absl::string_view *base_conjugation_suffix_data, - absl::string_view *conjugation_suffix_data, - absl::string_view *conjugation_suffix_index_data, - absl::string_view *usage_items_data, - absl::string_view *string_array_data) const = 0; -#endif // NO_USAGE_REWRITER - - // Gets the address and size of a sorted array of counter suffix values. - virtual absl::string_view GetCounterSuffixSortedArray() const = 0; - - // Gets the zero query prediction data. - virtual void GetZeroQueryData( - absl::string_view *zero_query_token_array_data, - absl::string_view *zero_query_string_array_data, - absl::string_view *zero_query_number_token_array_data, - absl::string_view *zero_query_number_string_array_data) const = 0; - - // Gets the data version string. - virtual absl::string_view GetDataVersion() const = 0; - - // Gets the offset and size of the given data section. - virtual std::optional> GetOffsetAndSize( - absl::string_view name) const { - return std::nullopt; - } - - protected: - DataManagerInterface() = default; -}; - -} // namespace mozc - -#endif // MOZC_DATA_MANAGER_DATA_MANAGER_INTERFACE_H_ diff --git a/src/data_manager/data_manager_test_base.cc b/src/data_manager/data_manager_test_base.cc index 1424dff9a..8a5a961c9 100644 --- a/src/data_manager/data_manager_test_base.cc +++ b/src/data_manager/data_manager_test_base.cc @@ -49,7 +49,7 @@ #include "converter/node.h" #include "converter/segmenter.h" #include "data_manager/connection_file_reader.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "prediction/suggestion_filter.h" #include "testing/gunit.h" @@ -60,7 +60,7 @@ using ::mozc::dictionary::PosMatcher; } // namespace DataManagerTestBase::DataManagerTestBase( - DataManagerInterface *data_manager, const size_t lsize, const size_t rsize, + DataManager *data_manager, const size_t lsize, const size_t rsize, IsBoundaryFunc is_boundary, const std::string &connection_txt_file, const int expected_resolution, std::vector dictionary_files, std::vector suggestion_filter_files) diff --git a/src/data_manager/data_manager_test_base.h b/src/data_manager/data_manager_test_base.h index 70cc4f984..23c1d7eae 100644 --- a/src/data_manager/data_manager_test_base.h +++ b/src/data_manager/data_manager_test_base.h @@ -40,14 +40,14 @@ namespace mozc { -class DataManagerInterface; +class DataManager; // Provides common unit tests for DataManager. class DataManagerTestBase : public ::testing::Test { protected: typedef bool (*IsBoundaryFunc)(uint16_t, uint16_t); - DataManagerTestBase(DataManagerInterface *data_manager, + DataManagerTestBase(DataManager *data_manager, // The following three are used in segmenter test. size_t lsize, size_t rsize, IsBoundaryFunc is_boundary, // The following two are used in connector test. @@ -71,7 +71,7 @@ class DataManagerTestBase : public ::testing::Test { void SuggestionFilterTest_IsBadSuggestion(); void CounterSuffixTest_ValidateTest(); - std::unique_ptr data_manager_; + std::unique_ptr data_manager_; const uint16_t lsize_; const uint16_t rsize_; IsBoundaryFunc is_boundary_; diff --git a/src/dictionary/BUILD.bazel b/src/dictionary/BUILD.bazel index 62c8c425f..9775d6514 100644 --- a/src/dictionary/BUILD.bazel +++ b/src/dictionary/BUILD.bazel @@ -515,7 +515,7 @@ mozc_cc_library( ":user_pos_interface", "//base/container:serialized_string_array", "//base/strings:assign", - "//data_manager:data_manager_interface", + "//data_manager", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", @@ -711,7 +711,7 @@ mozc_cc_library( "//base:text_normalizer", "//base:util", "//base/container:serialized_string_array", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:serialized_dictionary", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", diff --git a/src/dictionary/single_kanji_dictionary.cc b/src/dictionary/single_kanji_dictionary.cc index 64ac5d32a..b8dc30b1c 100644 --- a/src/dictionary/single_kanji_dictionary.cc +++ b/src/dictionary/single_kanji_dictionary.cc @@ -44,7 +44,7 @@ #include "base/container/serialized_string_array.h" #include "base/text_normalizer.h" #include "base/util.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" namespace mozc { @@ -161,8 +161,7 @@ class Uint32ArrayIterator { } // namespace -SingleKanjiDictionary::SingleKanjiDictionary( - const DataManagerInterface &data_manager) { +SingleKanjiDictionary::SingleKanjiDictionary(const DataManager &data_manager) { absl::string_view string_array_data; absl::string_view variant_type_array_data; absl::string_view variant_string_array_data; diff --git a/src/dictionary/single_kanji_dictionary.h b/src/dictionary/single_kanji_dictionary.h index 104547d04..69f8fa051 100644 --- a/src/dictionary/single_kanji_dictionary.h +++ b/src/dictionary/single_kanji_dictionary.h @@ -37,7 +37,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" namespace mozc { @@ -45,7 +45,7 @@ namespace dictionary { class SingleKanjiDictionary { public: - explicit SingleKanjiDictionary(const DataManagerInterface &data_manager); + explicit SingleKanjiDictionary(const DataManager &data_manager); SingleKanjiDictionary(const SingleKanjiDictionary &) = delete; SingleKanjiDictionary &operator=(const SingleKanjiDictionary &) = delete; diff --git a/src/dictionary/user_pos.cc b/src/dictionary/user_pos.cc index b0127951f..9f76088d4 100644 --- a/src/dictionary/user_pos.cc +++ b/src/dictionary/user_pos.cc @@ -44,7 +44,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" #include "base/strings/assign.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" namespace mozc { namespace dictionary { @@ -176,7 +176,7 @@ bool UserPos::GetTokens(absl::string_view key, absl::string_view value, } std::unique_ptr UserPos::CreateFromDataManager( - const DataManagerInterface &manager) { + const DataManager &manager) { absl::string_view token_array_data, string_array_data; manager.GetUserPosData(&token_array_data, &string_array_data); return std::make_unique(token_array_data, string_array_data); diff --git a/src/dictionary/user_pos.h b/src/dictionary/user_pos.h index 717d47e3c..8333d8be5 100644 --- a/src/dictionary/user_pos.h +++ b/src/dictionary/user_pos.h @@ -40,7 +40,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/user_pos_interface.h" namespace mozc { @@ -180,7 +180,7 @@ class UserPos : public UserPosInterface { using const_iterator = iterator; static std::unique_ptr CreateFromDataManager( - const DataManagerInterface &manager); + const DataManager &manager); // Initializes the user pos from the given binary data. The provided byte // data must outlive this instance. diff --git a/src/engine/BUILD.bazel b/src/engine/BUILD.bazel index 0421b6202..d15f63a23 100644 --- a/src/engine/BUILD.bazel +++ b/src/engine/BUILD.bazel @@ -72,7 +72,6 @@ mozc_cc_test( "//base:hash", "//base/file:temp_dir", "//data_manager", - "//data_manager:data_manager_interface", "//protocol:engine_builder_cc_proto", "//testing:gunit_main", "//testing:mozctest", @@ -140,7 +139,7 @@ mozc_cc_library( ":supplemental_model_interface", "//converter:connector", "//converter:segmenter", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:dictionary_impl", "//dictionary:dictionary_interface", "//dictionary:pos_group", @@ -196,7 +195,7 @@ mozc_cc_library( "//converter:converter_interface", "//converter:immutable_converter_interface", "//converter:immutable_converter_no_factory", - "//data_manager:data_manager_interface", + "//data_manager", "//prediction:dictionary_predictor", "//prediction:predictor", "//prediction:predictor_interface", diff --git a/src/engine/data_loader_test.cc b/src/engine/data_loader_test.cc index a75aa69e0..2cff5bcf2 100644 --- a/src/engine/data_loader_test.cc +++ b/src/engine/data_loader_test.cc @@ -46,7 +46,6 @@ #include "base/file_util.h" #include "base/hash.h" #include "data_manager/data_manager.h" -#include "data_manager/data_manager_interface.h" #include "protocol/engine_builder.pb.h" #include "testing/gmock.h" #include "testing/gunit.h" @@ -115,7 +114,7 @@ TEST_P(DataLoaderTest, AsyncBuild) { EXPECT_TRUE(loader.StartNewDataBuildTask( request_, [&](std::unique_ptr response) { - const DataManagerInterface &response_data_manager = + const DataManager &response_data_manager = response->modules->GetDataManager(); EXPECT_EQ(response_data_manager.GetDataVersion(), expected_version); EXPECT_TRUE(response_data_manager.GetFilename()); diff --git a/src/engine/engine.cc b/src/engine/engine.cc index c40be49a9..210b419c8 100644 --- a/src/engine/engine.cc +++ b/src/engine/engine.cc @@ -44,7 +44,7 @@ #include "converter/converter_interface.h" #include "converter/immutable_converter.h" #include "converter/immutable_converter_interface.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "engine/data_loader.h" #include "engine/modules.h" #include "engine/supplemental_model_interface.h" @@ -60,7 +60,7 @@ namespace mozc { absl::StatusOr> Engine::CreateDesktopEngine( - std::unique_ptr data_manager) { + std::unique_ptr data_manager) { constexpr bool kIsMobile = false; auto modules = std::make_unique(); @@ -73,7 +73,7 @@ absl::StatusOr> Engine::CreateDesktopEngine( } absl::StatusOr> Engine::CreateMobileEngine( - std::unique_ptr data_manager) { + std::unique_ptr data_manager) { constexpr bool kIsMobile = true; auto modules = std::make_unique(); diff --git a/src/engine/engine.h b/src/engine/engine.h index cfce5d1ff..3a59d368a 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -40,7 +40,7 @@ #include "absl/strings/string_view.h" #include "converter/converter.h" #include "converter/converter_interface.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "engine/data_loader.h" #include "engine/engine_interface.h" #include "engine/minimal_engine.h" @@ -62,7 +62,7 @@ class Engine : public EngineInterface { // Creates an instance with desktop configuration from a data manager. The // ownership of data manager is passed to the engine instance. static absl::StatusOr> CreateDesktopEngine( - std::unique_ptr data_manager); + std::unique_ptr data_manager); // Helper function for the above factory, where data manager is instantiated // by a default constructor. Intended to be used for OssDataManager etc. @@ -74,7 +74,7 @@ class Engine : public EngineInterface { // Creates an instance with mobile configuration from a data manager. The // ownership of data manager is passed to the engine instance. static absl::StatusOr> CreateMobileEngine( - std::unique_ptr data_manager); + std::unique_ptr data_manager); // Helper function for the above factory, where data manager is instantiated // by a default constructor. Intended to be used for OssDataManager etc. diff --git a/src/engine/modules.cc b/src/engine/modules.cc index daa3927e2..d6774eb78 100644 --- a/src/engine/modules.cc +++ b/src/engine/modules.cc @@ -44,7 +44,7 @@ #include "absl/types/span.h" #include "converter/connector.h" #include "converter/segmenter.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/dictionary_impl.h" #include "dictionary/dictionary_interface.h" #include "dictionary/pos_group.h" @@ -70,8 +70,7 @@ using ::mozc::dictionary::ValueDictionary; namespace mozc { namespace engine { -absl::Status Modules::Init( - std::unique_ptr data_manager) { +absl::Status Modules::Init(std::unique_ptr data_manager) { #define RETURN_IF_NULL(ptr) \ do { \ if (!(ptr)) \ diff --git a/src/engine/modules.h b/src/engine/modules.h index 63fec8187..44a8122e5 100644 --- a/src/engine/modules.h +++ b/src/engine/modules.h @@ -37,7 +37,7 @@ #include "absl/status/status.h" #include "converter/connector.h" #include "converter/segmenter.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/pos_group.h" #include "dictionary/pos_matcher.h" @@ -56,7 +56,7 @@ class Modules { Modules(const Modules &) = delete; Modules &operator=(const Modules &) = delete; - absl::Status Init(std::unique_ptr data_manager); + absl::Status Init(std::unique_ptr data_manager); // Preset functions must be called before Init. void PresetPosMatcher( @@ -74,7 +74,7 @@ class Modules { std::unique_ptr single_kanji_prediction_aggregator); - const DataManagerInterface &GetDataManager() const { + const DataManager &GetDataManager() const { // DataManager must be valid. DCHECK(data_manager_); return *data_manager_; @@ -128,7 +128,7 @@ class Modules { private: bool initialized_ = false; - std::unique_ptr data_manager_; + std::unique_ptr data_manager_; std::unique_ptr pos_matcher_; std::unique_ptr suppression_dictionary_; Connector connector_; diff --git a/src/prediction/BUILD.bazel b/src/prediction/BUILD.bazel index 6be21a481..e239e9259 100644 --- a/src/prediction/BUILD.bazel +++ b/src/prediction/BUILD.bazel @@ -295,7 +295,7 @@ mozc_cc_test( "//converter:converter_mock", "//converter:immutable_converter_interface", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager/testing:mock_data_manager", "//dictionary:dictionary_interface", "//dictionary:dictionary_mock", @@ -377,7 +377,7 @@ mozc_cc_library( "//base/strings:assign", "//composer", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:pos_matcher", "//dictionary:single_kanji_dictionary", "//protocol:commands_cc_proto", diff --git a/src/prediction/dictionary_prediction_aggregator_test.cc b/src/prediction/dictionary_prediction_aggregator_test.cc index 28ddb1612..7538bb975 100644 --- a/src/prediction/dictionary_prediction_aggregator_test.cc +++ b/src/prediction/dictionary_prediction_aggregator_test.cc @@ -55,7 +55,7 @@ #include "converter/converter_mock.h" #include "converter/immutable_converter_interface.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/testing/mock_data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/dictionary_mock.h" @@ -373,8 +373,7 @@ class MockImmutableConverter : public ImmutableConverterInterface { class MockSingleKanjiPredictionAggregator : public SingleKanjiPredictionAggregator { public: - explicit MockSingleKanjiPredictionAggregator( - const DataManagerInterface &data_manager) + explicit MockSingleKanjiPredictionAggregator(const DataManager &data_manager) : SingleKanjiPredictionAggregator(data_manager) {} ~MockSingleKanjiPredictionAggregator() override = default; MOCK_METHOD(std::vector, AggregateResults, diff --git a/src/prediction/single_kanji_prediction_aggregator.cc b/src/prediction/single_kanji_prediction_aggregator.cc index c8316f218..0ab70c571 100644 --- a/src/prediction/single_kanji_prediction_aggregator.cc +++ b/src/prediction/single_kanji_prediction_aggregator.cc @@ -40,7 +40,7 @@ #include "base/util.h" #include "composer/composer.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "dictionary/single_kanji_dictionary.h" #include "prediction/result.h" @@ -71,7 +71,7 @@ void StripLastChar(std::string *key) { } // namespace SingleKanjiPredictionAggregator::SingleKanjiPredictionAggregator( - const DataManagerInterface &data_manager) + const DataManager &data_manager) : single_kanji_dictionary_( new dictionary::SingleKanjiDictionary(data_manager)), pos_matcher_(std::make_unique( diff --git a/src/prediction/single_kanji_prediction_aggregator.h b/src/prediction/single_kanji_prediction_aggregator.h index 30b1f27af..7d3246ef1 100644 --- a/src/prediction/single_kanji_prediction_aggregator.h +++ b/src/prediction/single_kanji_prediction_aggregator.h @@ -38,7 +38,7 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "dictionary/single_kanji_dictionary.h" #include "prediction/prediction_aggregator_interface.h" @@ -49,8 +49,7 @@ namespace mozc::prediction { class SingleKanjiPredictionAggregator : public PredictionAggregatorInterface { public: - explicit SingleKanjiPredictionAggregator( - const DataManagerInterface &data_manager); + explicit SingleKanjiPredictionAggregator(const DataManager &data_manager); ~SingleKanjiPredictionAggregator() override; std::vector AggregateResults(const ConversionRequest &request, diff --git a/src/rewriter/BUILD.bazel b/src/rewriter/BUILD.bazel index 79f992a11..ea203b6d1 100644 --- a/src/rewriter/BUILD.bazel +++ b/src/rewriter/BUILD.bazel @@ -81,7 +81,7 @@ mozc_cc_library( "//base:util", "//base:vlog", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:pos_matcher", "//request:conversion_request", "//storage:existence_filter", @@ -292,7 +292,7 @@ mozc_cc_library( "//base/container:serialized_string_array", "//config:character_form_manager", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:pos_matcher", "//protocol:commands_cc_proto", "//protocol:config_cc_proto", @@ -521,7 +521,7 @@ mozc_cc_library( "//base/strings:assign", "//converter:converter_interface", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:serialized_dictionary", "//protocol:commands_cc_proto", "//protocol:config_cc_proto", @@ -567,7 +567,7 @@ mozc_cc_library( ":rewriter_util", "//base:vlog", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:serialized_dictionary", "//protocol:commands_cc_proto", "//protocol:config_cc_proto", @@ -861,7 +861,7 @@ mozc_cc_library( ], hdrs = ["dictionary_generator.h"], deps = [ - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:pos_matcher", "//dictionary:user_pos", "//dictionary:user_pos_interface", @@ -946,7 +946,7 @@ mozc_cc_library( "//base/container:serialized_string_array", "//base/strings:assign", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:emoji_data", "//protocol:commands_cc_proto", "//protocol:config_cc_proto", @@ -996,7 +996,7 @@ mozc_cc_library( "//base:vlog", "//base/strings:assign", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:serialized_dictionary", "//dictionary:pos_matcher", "//dictionary:single_kanji_dictionary", @@ -1073,7 +1073,7 @@ mozc_cc_library( "//base:vlog", "//base/container:serialized_string_array", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:pos_matcher", "//request:conversion_request", "@com_google_absl//absl/log", @@ -1222,7 +1222,7 @@ mozc_cc_library( "//base:util", "//base/container:serialized_string_array", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:emoji_data", "//protocol:commands_cc_proto", "//request:conversion_request", @@ -1314,7 +1314,7 @@ mozc_cc_library( "//base:vlog", "//base/container:serialized_string_array", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:dictionary_interface", "//dictionary:pos_matcher", "//protocol:config_cc_proto", @@ -1373,7 +1373,7 @@ mozc_cc_library( ":rewriter_interface", "//base/container:serialized_string_array", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//protocol:config_cc_proto", "//request:conversion_request", "@com_google_absl//absl/log:check", @@ -1407,7 +1407,7 @@ mozc_cc_library( ":rewriter_interface", "//base:util", "//converter:segments", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager:serialized_dictionary", "//protocol:commands_cc_proto", "//request:conversion_request", @@ -1482,7 +1482,7 @@ mozc_cc_library( ":version_rewriter", ":zipcode_rewriter", "//converter:converter_interface", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:dictionary_interface", "//dictionary:pos_group", "//dictionary:pos_matcher", diff --git a/src/rewriter/a11y_description_rewriter.cc b/src/rewriter/a11y_description_rewriter.cc index 842018337..a5a237cc6 100644 --- a/src/rewriter/a11y_description_rewriter.cc +++ b/src/rewriter/a11y_description_rewriter.cc @@ -39,7 +39,7 @@ #include "absl/strings/string_view.h" #include "base/util.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "protocol/commands.pb.h" #include "request/conversion_request.h" @@ -157,7 +157,7 @@ std::string A11yDescriptionRewriter::GetKanaCharacterLabel( } A11yDescriptionRewriter::A11yDescriptionRewriter( - const DataManagerInterface *data_manager) + const DataManager *data_manager) : small_letter_set_( {// Small hiragana U'ぁ', U'ぃ', U'ぅ', U'ぇ', U'ぉ', U'ゃ', U'ゅ', U'ょ', U'っ', U'ゎ', diff --git a/src/rewriter/a11y_description_rewriter.h b/src/rewriter/a11y_description_rewriter.h index cf6ea2ef1..fb278196e 100644 --- a/src/rewriter/a11y_description_rewriter.h +++ b/src/rewriter/a11y_description_rewriter.h @@ -36,7 +36,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -45,7 +45,7 @@ namespace mozc { class A11yDescriptionRewriter : public RewriterInterface { public: - explicit A11yDescriptionRewriter(const DataManagerInterface *data_manager); + explicit A11yDescriptionRewriter(const DataManager *data_manager); A11yDescriptionRewriter(const A11yDescriptionRewriter &) = delete; A11yDescriptionRewriter &operator=(const A11yDescriptionRewriter &) = delete; diff --git a/src/rewriter/collocation_rewriter.cc b/src/rewriter/collocation_rewriter.cc index 15321db5a..86b0a49c0 100644 --- a/src/rewriter/collocation_rewriter.cc +++ b/src/rewriter/collocation_rewriter.cc @@ -50,7 +50,7 @@ #include "base/util.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "request/conversion_request.h" #include "rewriter/collocation_util.h" @@ -557,7 +557,7 @@ bool CollocationRewriter::RewriteCollocation(Segments *segments) const { } std::unique_ptr CollocationRewriter::Create( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { absl::StatusOr collocation_filter = CollocationFilter::Create(data_manager.GetCollocationData()); if (!collocation_filter.ok()) { diff --git a/src/rewriter/collocation_rewriter.h b/src/rewriter/collocation_rewriter.h index 1a13de3c7..8ee4b113a 100644 --- a/src/rewriter/collocation_rewriter.h +++ b/src/rewriter/collocation_rewriter.h @@ -38,7 +38,7 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -90,7 +90,7 @@ class CollocationRewriter : public RewriterInterface { suppression_filter_(std::move(suppression_filter)) {} static std::unique_ptr Create( - const DataManagerInterface &data_manager); + const DataManager &data_manager); bool Rewrite(const ConversionRequest &request, Segments *segments) const override; diff --git a/src/rewriter/correction_rewriter.cc b/src/rewriter/correction_rewriter.cc index 9de6cb32f..c50932c2a 100644 --- a/src/rewriter/correction_rewriter.cc +++ b/src/rewriter/correction_rewriter.cc @@ -40,7 +40,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "protocol/config.pb.h" #include "request/conversion_request.h" @@ -91,7 +91,7 @@ CorrectionRewriter::CorrectionRewriter( // static std::unique_ptr CorrectionRewriter::CreateCorrectionRewriter( - const DataManagerInterface *data_manager) { + const DataManager *data_manager) { absl::string_view value_array_data, error_array_data, correction_array_data; data_manager->GetReadingCorrectionData(&value_array_data, &error_array_data, &correction_array_data); diff --git a/src/rewriter/correction_rewriter.h b/src/rewriter/correction_rewriter.h index 5d479bf3f..cd2f3bf54 100644 --- a/src/rewriter/correction_rewriter.h +++ b/src/rewriter/correction_rewriter.h @@ -36,7 +36,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -48,7 +48,7 @@ class CorrectionRewriter : public RewriterInterface { // default provided by data_manager. The caller takes the ownership of the // instance. static std::unique_ptr CreateCorrectionRewriter( - const DataManagerInterface *data_manager); + const DataManager *data_manager); CorrectionRewriter(absl::string_view value_array_data, absl::string_view error_array_data, diff --git a/src/rewriter/dictionary_generator.cc b/src/rewriter/dictionary_generator.cc index 04ea6849b..fc1fa8538 100644 --- a/src/rewriter/dictionary_generator.cc +++ b/src/rewriter/dictionary_generator.cc @@ -38,7 +38,7 @@ #include #include "absl/log/check.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "dictionary/user_pos.h" @@ -75,7 +75,7 @@ bool operator<(const Token &lhs, const Token &rhs) { } DictionaryGenerator::DictionaryGenerator( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { const dictionary::PosMatcher pos_matcher(data_manager.GetPosMatcherData()); open_bracket_id_ = pos_matcher.GetOpenBracketId(); close_bracket_id_ = pos_matcher.GetCloseBracketId(); diff --git a/src/rewriter/dictionary_generator.h b/src/rewriter/dictionary_generator.h index bcef54066..8abba7113 100644 --- a/src/rewriter/dictionary_generator.h +++ b/src/rewriter/dictionary_generator.h @@ -39,7 +39,7 @@ #include "absl/container/btree_set.h" #include "absl/strings/str_format.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/user_pos_interface.h" namespace mozc { @@ -80,7 +80,7 @@ bool operator<(const Token &lhs, const Token &rhs); class DictionaryGenerator { public: - explicit DictionaryGenerator(const DataManagerInterface &data_manager); + explicit DictionaryGenerator(const DataManager &data_manager); DictionaryGenerator(DictionaryGenerator &&) = default; DictionaryGenerator &operator=(DictionaryGenerator &&) = default; diff --git a/src/rewriter/emoji_rewriter.cc b/src/rewriter/emoji_rewriter.cc index 4db9b8985..c687f823d 100644 --- a/src/rewriter/emoji_rewriter.cc +++ b/src/rewriter/emoji_rewriter.cc @@ -46,7 +46,7 @@ #include "base/strings/assign.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/emoji_data.h" #include "protocol/commands.pb.h" #include "protocol/config.pb.h" @@ -141,7 +141,7 @@ std::vector> CreateEmojiData( } } // namespace -EmojiRewriter::EmojiRewriter(const DataManagerInterface &data_manager) { +EmojiRewriter::EmojiRewriter(const DataManager &data_manager) { absl::string_view string_array_data; data_manager.GetEmojiRewriterData(&token_array_data_, &string_array_data); DCHECK(SerializedStringArray::VerifyData(string_array_data)); diff --git a/src/rewriter/emoji_rewriter.h b/src/rewriter/emoji_rewriter.h index 16473e6ee..0be60a069 100644 --- a/src/rewriter/emoji_rewriter.h +++ b/src/rewriter/emoji_rewriter.h @@ -36,7 +36,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/emoji_data.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -71,7 +71,7 @@ class EmojiRewriter : public RewriterInterface { static constexpr size_t kEmojiDataByteLength = 28; using IteratorRange = std::pair; - explicit EmojiRewriter(const DataManagerInterface &data_manager); + explicit EmojiRewriter(const DataManager &data_manager); EmojiRewriter(const EmojiRewriter &) = delete; EmojiRewriter &operator=(const EmojiRewriter &) = delete; diff --git a/src/rewriter/emoticon_rewriter.cc b/src/rewriter/emoticon_rewriter.cc index 128cd4d20..b34f7f93d 100644 --- a/src/rewriter/emoticon_rewriter.cc +++ b/src/rewriter/emoticon_rewriter.cc @@ -42,7 +42,7 @@ #include "absl/strings/string_view.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "protocol/commands.pb.h" #include "protocol/config.pb.h" @@ -217,7 +217,7 @@ bool EmoticonRewriter::RewriteCandidate(Segments *segments) const { } std::unique_ptr EmoticonRewriter::CreateFromDataManager( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { absl::string_view token_array_data, string_array_data; data_manager.GetEmoticonRewriterData(&token_array_data, &string_array_data); return std::make_unique(token_array_data, diff --git a/src/rewriter/emoticon_rewriter.h b/src/rewriter/emoticon_rewriter.h index db69e0b05..02b02446e 100644 --- a/src/rewriter/emoticon_rewriter.h +++ b/src/rewriter/emoticon_rewriter.h @@ -35,7 +35,7 @@ #include "absl/random/random.h" #include "absl/strings/string_view.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -45,7 +45,7 @@ namespace mozc { class EmoticonRewriter : public RewriterInterface { public: static std::unique_ptr CreateFromDataManager( - const DataManagerInterface &data_manager); + const DataManager &data_manager); EmoticonRewriter(absl::string_view token_array_data, absl::string_view string_array_data); diff --git a/src/rewriter/environmental_filter_rewriter.cc b/src/rewriter/environmental_filter_rewriter.cc index a58a1bf5b..2cac4dfeb 100644 --- a/src/rewriter/environmental_filter_rewriter.cc +++ b/src/rewriter/environmental_filter_rewriter.cc @@ -49,7 +49,7 @@ #include "base/text_normalizer.h" #include "base/util.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/emoji_data.h" #include "protocol/commands.pb.h" #include "request/conversion_request.h" @@ -366,7 +366,7 @@ int EnvironmentalFilterRewriter::capability( } EnvironmentalFilterRewriter::EnvironmentalFilterRewriter( - const DataManagerInterface &data_manager) { + const DataManager &data_manager) { absl::string_view token_array_data; absl::string_view string_array_data; diff --git a/src/rewriter/environmental_filter_rewriter.h b/src/rewriter/environmental_filter_rewriter.h index c0c669eb9..5b673d422 100644 --- a/src/rewriter/environmental_filter_rewriter.h +++ b/src/rewriter/environmental_filter_rewriter.h @@ -59,7 +59,7 @@ #include "absl/types/span.h" #include "base/text_normalizer.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -100,7 +100,7 @@ class EnvironmentalFilterRewriter : public RewriterInterface { // and |value_list|. If NULL pointer is passed to it, Mozc process // terminates with an error. explicit EnvironmentalFilterRewriter( - const DataManagerInterface &data_manager); + const DataManager &data_manager); int capability(const ConversionRequest &request) const override; diff --git a/src/rewriter/focus_candidate_rewriter.cc b/src/rewriter/focus_candidate_rewriter.cc index 0b2e1f3c0..9cf8f67da 100644 --- a/src/rewriter/focus_candidate_rewriter.cc +++ b/src/rewriter/focus_candidate_rewriter.cc @@ -42,7 +42,7 @@ #include "base/util.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "rewriter/number_compound_util.h" namespace mozc { @@ -129,7 +129,7 @@ bool RewriteNumber(Segment *segment, const Segment::Candidate &candidate) { } // namespace FocusCandidateRewriter::FocusCandidateRewriter( - const DataManagerInterface *data_manager) + const DataManager *data_manager) : pos_matcher_(data_manager->GetPosMatcherData()) { absl::string_view data = data_manager->GetCounterSuffixSortedArray(); // Data manager is responsible for providing a valid data. Just verify data diff --git a/src/rewriter/focus_candidate_rewriter.h b/src/rewriter/focus_candidate_rewriter.h index 18f951fd3..1e63ea577 100644 --- a/src/rewriter/focus_candidate_rewriter.h +++ b/src/rewriter/focus_candidate_rewriter.h @@ -42,12 +42,12 @@ namespace mozc { -class DataManagerInterface; +class DataManager; struct CounterSuffixEntry; class FocusCandidateRewriter : public RewriterInterface { public: - explicit FocusCandidateRewriter(const DataManagerInterface *data_manager); + explicit FocusCandidateRewriter(const DataManager *data_manager); FocusCandidateRewriter(const FocusCandidateRewriter &) = delete; FocusCandidateRewriter &operator=(const FocusCandidateRewriter &) = delete; ~FocusCandidateRewriter() override; diff --git a/src/rewriter/number_compound_util.h b/src/rewriter/number_compound_util.h index bbf77c8e5..0f418f4f9 100644 --- a/src/rewriter/number_compound_util.h +++ b/src/rewriter/number_compound_util.h @@ -60,7 +60,7 @@ enum NumberScriptType { // "一階" can be split as "一" + "階". At the same time, script type of // number can be obtained. A sorted array of counter suffix needs to be // provided, which can be obtained using data manager; see -// data_manager/data_manager_interface.h. Returns false if the input cannot be +// data_manager/data_manager.h. Returns false if the input cannot be // split. bool SplitStringIntoNumberAndCounterSuffix( const SerializedStringArray &suffix_array, absl::string_view input, diff --git a/src/rewriter/number_rewriter.cc b/src/rewriter/number_rewriter.cc index 82b59d051..985959679 100644 --- a/src/rewriter/number_rewriter.cc +++ b/src/rewriter/number_rewriter.cc @@ -50,7 +50,7 @@ #include "base/vlog.h" #include "config/character_form_manager.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "protocol/commands.pb.h" #include "protocol/config.pb.h" @@ -455,7 +455,7 @@ std::vector GetNumbersInDefaultOrder( } // namespace -NumberRewriter::NumberRewriter(const DataManagerInterface *data_manager) +NumberRewriter::NumberRewriter(const DataManager *data_manager) : pos_matcher_(data_manager->GetPosMatcherData()) { absl::string_view data = data_manager->GetCounterSuffixSortedArray(); // Data manager is responsible for providing a valid data. Just verify data diff --git a/src/rewriter/number_rewriter.h b/src/rewriter/number_rewriter.h index f49b0ab85..9b3c8d8bd 100644 --- a/src/rewriter/number_rewriter.h +++ b/src/rewriter/number_rewriter.h @@ -36,7 +36,7 @@ #include "base/container/serialized_string_array.h" #include "base/number_util.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "request/conversion_request.h" #include "rewriter/rewriter_interface.h" @@ -46,7 +46,7 @@ namespace mozc { // A rewriter to expand number styles (NumberUtil::NumberString::Style) class NumberRewriter : public RewriterInterface { public: - explicit NumberRewriter(const DataManagerInterface *data_manager); + explicit NumberRewriter(const DataManager *data_manager); NumberRewriter(const NumberRewriter &) = delete; NumberRewriter &operator=(const NumberRewriter &) = delete; ~NumberRewriter() override; diff --git a/src/rewriter/rewriter.cc b/src/rewriter/rewriter.cc index 1df55a24b..d5686b689 100644 --- a/src/rewriter/rewriter.cc +++ b/src/rewriter/rewriter.cc @@ -33,7 +33,7 @@ #include "absl/flags/flag.h" #include "converter/converter_interface.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/pos_group.h" #include "dictionary/pos_matcher.h" @@ -87,7 +87,7 @@ namespace mozc { Rewriter::Rewriter(const engine::Modules &modules, const ConverterInterface &parent_converter) { - const DataManagerInterface *data_manager = &modules.GetDataManager(); + const DataManager *data_manager = &modules.GetDataManager(); const dictionary::DictionaryInterface *dictionary = modules.GetDictionary(); const dictionary::PosMatcher &pos_matcher = *modules.GetPosMatcher(); const dictionary::PosGroup *pos_group = modules.GetPosGroup(); diff --git a/src/rewriter/single_kanji_rewriter.cc b/src/rewriter/single_kanji_rewriter.cc index 289cc41fe..10997726d 100644 --- a/src/rewriter/single_kanji_rewriter.cc +++ b/src/rewriter/single_kanji_rewriter.cc @@ -42,7 +42,7 @@ #include "base/strings/assign.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "dictionary/pos_matcher.h" #include "dictionary/single_kanji_dictionary.h" @@ -100,7 +100,7 @@ void InsertNounPrefix(const PosMatcher &pos_matcher, Segment *segment, } // namespace SingleKanjiRewriter::SingleKanjiRewriter( - const DataManagerInterface &data_manager) + const DataManager &data_manager) : pos_matcher_(data_manager.GetPosMatcherData()), single_kanji_dictionary_( new dictionary::SingleKanjiDictionary(data_manager)) {} diff --git a/src/rewriter/single_kanji_rewriter.h b/src/rewriter/single_kanji_rewriter.h index 220a491c6..91661df41 100644 --- a/src/rewriter/single_kanji_rewriter.h +++ b/src/rewriter/single_kanji_rewriter.h @@ -37,7 +37,7 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/pos_matcher.h" #include "dictionary/single_kanji_dictionary.h" #include "request/conversion_request.h" @@ -47,7 +47,7 @@ namespace mozc { class SingleKanjiRewriter : public RewriterInterface { public: - explicit SingleKanjiRewriter(const DataManagerInterface &data_manager); + explicit SingleKanjiRewriter(const DataManager &data_manager); ~SingleKanjiRewriter() override; int capability(const ConversionRequest &request) const override; diff --git a/src/rewriter/symbol_rewriter.cc b/src/rewriter/symbol_rewriter.cc index aff5339a0..eb84835ea 100644 --- a/src/rewriter/symbol_rewriter.cc +++ b/src/rewriter/symbol_rewriter.cc @@ -46,7 +46,7 @@ #include "base/vlog.h" #include "converter/converter_interface.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "data_manager/serialized_dictionary.h" #include "protocol/commands.pb.h" #include "protocol/config.pb.h" @@ -356,7 +356,7 @@ bool SymbolRewriter::RewriteEntireCandidate(const ConversionRequest &request, } SymbolRewriter::SymbolRewriter(const ConverterInterface *parent_converter, - const DataManagerInterface *data_manager) + const DataManager *data_manager) : parent_converter_(parent_converter) { DCHECK(parent_converter_); absl::string_view token_array_data, string_array_data; diff --git a/src/rewriter/symbol_rewriter.h b/src/rewriter/symbol_rewriter.h index 87d3a64a8..c575c7876 100644 --- a/src/rewriter/symbol_rewriter.h +++ b/src/rewriter/symbol_rewriter.h @@ -43,14 +43,14 @@ namespace mozc { class ConversionRequest; class ConverterInterface; -class DataManagerInterface; +class DataManager; class Segment; class Segments; class SymbolRewriter : public RewriterInterface { public: explicit SymbolRewriter(const ConverterInterface *parent_converter, - const DataManagerInterface *data_manager); + const DataManager *data_manager); ~SymbolRewriter() override = default; int capability(const ConversionRequest &request) const override; diff --git a/src/rewriter/usage_rewriter.cc b/src/rewriter/usage_rewriter.cc index df09c94a1..86fca9d61 100644 --- a/src/rewriter/usage_rewriter.cc +++ b/src/rewriter/usage_rewriter.cc @@ -43,7 +43,7 @@ #include "base/util.h" #include "base/vlog.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/pos_matcher.h" #include "protocol/config.pb.h" @@ -53,7 +53,7 @@ namespace mozc { using ::mozc::dictionary::DictionaryInterface; -UsageRewriter::UsageRewriter(const DataManagerInterface *data_manager, +UsageRewriter::UsageRewriter(const DataManager *data_manager, const DictionaryInterface *dictionary) : pos_matcher_(data_manager->GetPosMatcherData()), dictionary_(dictionary), diff --git a/src/rewriter/usage_rewriter.h b/src/rewriter/usage_rewriter.h index e06c35ec8..ab0cedf93 100644 --- a/src/rewriter/usage_rewriter.h +++ b/src/rewriter/usage_rewriter.h @@ -42,7 +42,7 @@ #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" #include "converter/segments.h" -#include "data_manager/data_manager_interface.h" +#include "data_manager/data_manager.h" #include "dictionary/dictionary_interface.h" #include "dictionary/pos_matcher.h" #include "request/conversion_request.h" @@ -53,7 +53,7 @@ namespace mozc { class UsageRewriter : public RewriterInterface { public: - UsageRewriter(const DataManagerInterface *data_manager, + UsageRewriter(const DataManager *data_manager, const dictionary::DictionaryInterface *dictionary); ~UsageRewriter() override = default; bool Rewrite(const ConversionRequest &request, diff --git a/src/session/BUILD.bazel b/src/session/BUILD.bazel index 4d699bb8a..98510cd65 100644 --- a/src/session/BUILD.bazel +++ b/src/session/BUILD.bazel @@ -292,7 +292,7 @@ mozc_cc_library( "//config:character_form_manager", "//config:config_handler", "//converter:converter_interface", - "//data_manager:data_manager_interface", + "//data_manager", "//dictionary:user_dictionary_session_handler", "//engine", "//engine:engine_interface", @@ -709,7 +709,7 @@ mozc_cc_binary( "//base:init_mozc", "//base:system_util", "//base/protobuf:message", - "//data_manager:data_manager_interface", + "//data_manager", "//data_manager/oss:oss_data_manager", "//data_manager/testing:mock_data_manager", "//engine", diff --git a/src/session/session_handler_main.cc b/src/session/session_handler_main.cc index 2eacf3c90..24a714c9f 100644 --- a/src/session/session_handler_main.cc +++ b/src/session/session_handler_main.cc @@ -179,7 +179,7 @@ void ParseLine(session::SessionHandlerInterpreter &handler, std::string line) { } } -std::unique_ptr CreateDataManager( +std::unique_ptr CreateDataManager( const std::string &dictionary) { if (dictionary == "oss") { return std::make_unique();