• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEXT_TRANSLATION_LOADER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEXT_TRANSLATION_LOADER_H
18 
19 #include <functional>
20 #include <memory>
21 #include "interfaces/inner_api/ace/ai/text_translation_interface.h"
22 
23 namespace OHOS::Ace {
24 using TextTranslationInstance = std::unique_ptr<TextTranslationInterface,
25     std::function<void (TextTranslationInterface*)>>;
26 
27 class TextTranslationLoader : public std::enable_shared_from_this<TextTranslationLoader> {
28 public:
29     static std::shared_ptr<TextTranslationLoader> Load();
30     ~TextTranslationLoader();
31     TextTranslationLoader() = default;
32 
33     TextTranslationLoader(const TextTranslationLoader&) = delete;
34     TextTranslationLoader(TextTranslationLoader&&) = delete;
35     TextTranslationLoader& operator=(const TextTranslationLoader&) = delete;
36     TextTranslationLoader& operator=(TextTranslationLoader&&) = delete;
37 
38     TextTranslationInstance CreateTextTranslation();
39 
40 private:
41     bool Init();
42     void Close();
43 
44     void *mLibraryHandle_ = nullptr;
45     TextTranslationInterface* (*mCreateTextTranslationInstance_)() = nullptr;
46     void (*mDestoryTextTranslationInstance_)(TextTranslationInterface*) = nullptr;
47 };
48 } // namespace OHOS::Ace
49 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEXT_TRANSLATION_LOADER_H
50