123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_PREVIEW_HELPER_H 1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_PREVIEW_HELPER_H 1823b3eb3cSopenharmony_ci 1923b3eb3cSopenharmony_ci#include <functional> 2023b3eb3cSopenharmony_ci#include <string> 2123b3eb3cSopenharmony_ci 2223b3eb3cSopenharmony_ci#include "base/utils/macros.h" 2323b3eb3cSopenharmony_ci 2423b3eb3cSopenharmony_cinamespace OHOS::Ace::Platform { 2523b3eb3cSopenharmony_ciusing CallbackTypeIsCurrentRunnerThread = std::function<bool(void)>; 2623b3eb3cSopenharmony_ciusing CallbackTypePostTask = std::function<void(const std::function<void()>&, int64_t)>; 2723b3eb3cSopenharmony_ciusing CallbackTypeHspBufferTracker = std::function<bool(const std::string&, uint8_t**, size_t*, std::string&)>; 2823b3eb3cSopenharmony_ciusing CallbackTypeSetClipboardData = std::function<void(const std::string&)>; 2923b3eb3cSopenharmony_ciusing CallbackTypeGetClipboardData = std::function<const std::string(void)>; 3023b3eb3cSopenharmony_ciusing CallbackFlushEmpty = std::function<bool(const uint64_t)>; 3123b3eb3cSopenharmony_ciclass ACE_FORCE_EXPORT AcePreviewHelper { 3223b3eb3cSopenharmony_cipublic: 3323b3eb3cSopenharmony_ci static AcePreviewHelper* GetInstance(); 3423b3eb3cSopenharmony_ci ~AcePreviewHelper() = default; 3523b3eb3cSopenharmony_ci 3623b3eb3cSopenharmony_ci void SetCallbackFlushEmpty(const CallbackFlushEmpty&& flushEmpty) 3723b3eb3cSopenharmony_ci { 3823b3eb3cSopenharmony_ci flushEmpty_ = flushEmpty; 3923b3eb3cSopenharmony_ci } 4023b3eb3cSopenharmony_ci 4123b3eb3cSopenharmony_ci CallbackFlushEmpty GetCallbackFlushEmpty() 4223b3eb3cSopenharmony_ci { 4323b3eb3cSopenharmony_ci return flushEmpty_; 4423b3eb3cSopenharmony_ci } 4523b3eb3cSopenharmony_ci 4623b3eb3cSopenharmony_ci void SetCallbackOfPostTask(const CallbackTypePostTask&& postTask) 4723b3eb3cSopenharmony_ci { 4823b3eb3cSopenharmony_ci postTask_ = postTask; 4923b3eb3cSopenharmony_ci } 5023b3eb3cSopenharmony_ci 5123b3eb3cSopenharmony_ci CallbackTypePostTask GetCallbackOfPostTask() 5223b3eb3cSopenharmony_ci { 5323b3eb3cSopenharmony_ci return postTask_; 5423b3eb3cSopenharmony_ci } 5523b3eb3cSopenharmony_ci 5623b3eb3cSopenharmony_ci void SetCallbackOfIsCurrentRunnerThread(const CallbackTypeIsCurrentRunnerThread&& isCurrentRunnerThread) 5723b3eb3cSopenharmony_ci { 5823b3eb3cSopenharmony_ci isCurrentRunnerThread_ = isCurrentRunnerThread; 5923b3eb3cSopenharmony_ci } 6023b3eb3cSopenharmony_ci 6123b3eb3cSopenharmony_ci CallbackTypeIsCurrentRunnerThread GetCallbackOfIsCurrentRunnerThread() 6223b3eb3cSopenharmony_ci { 6323b3eb3cSopenharmony_ci return isCurrentRunnerThread_; 6423b3eb3cSopenharmony_ci } 6523b3eb3cSopenharmony_ci 6623b3eb3cSopenharmony_ci void SetCallbackOfHspBufferTracker(const CallbackTypeHspBufferTracker&& hspBufferTracker) 6723b3eb3cSopenharmony_ci { 6823b3eb3cSopenharmony_ci hspBufferTracker_ = hspBufferTracker; 6923b3eb3cSopenharmony_ci } 7023b3eb3cSopenharmony_ci 7123b3eb3cSopenharmony_ci CallbackTypeHspBufferTracker GetCallbackOfHspBufferTracker() 7223b3eb3cSopenharmony_ci { 7323b3eb3cSopenharmony_ci return hspBufferTracker_; 7423b3eb3cSopenharmony_ci } 7523b3eb3cSopenharmony_ci 7623b3eb3cSopenharmony_ci void SetCallbackOfSetClipboardData(const CallbackTypeSetClipboardData&& setClipboardData) 7723b3eb3cSopenharmony_ci { 7823b3eb3cSopenharmony_ci setClipboardData_ = std::move(setClipboardData); 7923b3eb3cSopenharmony_ci } 8023b3eb3cSopenharmony_ci 8123b3eb3cSopenharmony_ci CallbackTypeSetClipboardData GetCallbackOfSetClipboardData() 8223b3eb3cSopenharmony_ci { 8323b3eb3cSopenharmony_ci return setClipboardData_; 8423b3eb3cSopenharmony_ci } 8523b3eb3cSopenharmony_ci 8623b3eb3cSopenharmony_ci void SetCallbackOfGetClipboardData(const CallbackTypeGetClipboardData&& getClipboardData) 8723b3eb3cSopenharmony_ci { 8823b3eb3cSopenharmony_ci getClipboardData_ = std::move(getClipboardData); 8923b3eb3cSopenharmony_ci } 9023b3eb3cSopenharmony_ci 9123b3eb3cSopenharmony_ci CallbackTypeGetClipboardData GetCallbackOfGetClipboardData() 9223b3eb3cSopenharmony_ci { 9323b3eb3cSopenharmony_ci return getClipboardData_; 9423b3eb3cSopenharmony_ci } 9523b3eb3cSopenharmony_ci 9623b3eb3cSopenharmony_ciprivate: 9723b3eb3cSopenharmony_ci AcePreviewHelper() = default; 9823b3eb3cSopenharmony_ci AcePreviewHelper(const AcePreviewHelper&) = delete; 9923b3eb3cSopenharmony_ci AcePreviewHelper& operator=(const AcePreviewHelper&) = delete; 10023b3eb3cSopenharmony_ci 10123b3eb3cSopenharmony_ci CallbackTypePostTask postTask_ = nullptr; 10223b3eb3cSopenharmony_ci CallbackTypeIsCurrentRunnerThread isCurrentRunnerThread_ = nullptr; 10323b3eb3cSopenharmony_ci CallbackTypeHspBufferTracker hspBufferTracker_ = nullptr; 10423b3eb3cSopenharmony_ci CallbackTypeSetClipboardData setClipboardData_ = nullptr; 10523b3eb3cSopenharmony_ci CallbackTypeGetClipboardData getClipboardData_ = nullptr; 10623b3eb3cSopenharmony_ci CallbackFlushEmpty flushEmpty_ = nullptr; 10723b3eb3cSopenharmony_ci}; 10823b3eb3cSopenharmony_ci} // namespace OHOS::Ace::Platform 10923b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_PREVIEW_HELPER_H 110