15490a39dSopenharmony_ci/* 25490a39dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 35490a39dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 45490a39dSopenharmony_ci * you may not use this file except in compliance with the License. 55490a39dSopenharmony_ci * You may obtain a copy of the License at 65490a39dSopenharmony_ci * 75490a39dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 85490a39dSopenharmony_ci * 95490a39dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 105490a39dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 115490a39dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 125490a39dSopenharmony_ci * See the License for the specific language governing permissions and 135490a39dSopenharmony_ci * limitations under the License. 145490a39dSopenharmony_ci */ 155490a39dSopenharmony_ci#ifndef MSG_HANDLE_THREAD_H 165490a39dSopenharmony_ci#define MSG_HANDLE_THREAD_H 175490a39dSopenharmony_ci 185490a39dSopenharmony_ci#include <string> 195490a39dSopenharmony_ci#include "message_queue.h" 205490a39dSopenharmony_ci#include "base_thread.h" 215490a39dSopenharmony_ci 225490a39dSopenharmony_cinamespace OHOS { 235490a39dSopenharmony_cinamespace IntellVoiceUtils { 245490a39dSopenharmony_ciclass MsgHandleThread : public BaseThread { 255490a39dSopenharmony_cipublic: 265490a39dSopenharmony_ci MsgHandleThread(); 275490a39dSopenharmony_ci // for compatible with wakeup engine 285490a39dSopenharmony_ci explicit MsgHandleThread(std::shared_ptr<MessageQueue> callbackMsgQue); 295490a39dSopenharmony_ci explicit MsgHandleThread(MsgHandleThread *callbackThread); 305490a39dSopenharmony_ci ~MsgHandleThread() override; 315490a39dSopenharmony_ci bool SendMsg(Message msg); 325490a39dSopenharmony_ci bool SendMsg(std::shared_ptr<Message> msg); 335490a39dSopenharmony_ci bool SendSynMsg(std::shared_ptr<Message> msg); 345490a39dSopenharmony_ci void SetCallbackThread(MsgHandleThread *tmpCallbackThread); 355490a39dSopenharmony_ci 365490a39dSopenharmony_ciprotected: 375490a39dSopenharmony_ci // subclass should override this function most time 385490a39dSopenharmony_ci virtual bool HandleMsg(Message &msg); 395490a39dSopenharmony_ci virtual void SendbackMsg(Message msg); 405490a39dSopenharmony_ci 415490a39dSopenharmony_ciprivate: 425490a39dSopenharmony_ci void Run() override; 435490a39dSopenharmony_ci 445490a39dSopenharmony_ci std::shared_ptr<MessageQueue> callbackMsgQue_ = nullptr; 455490a39dSopenharmony_ci MessageQueue msgQue_; 465490a39dSopenharmony_ci MsgHandleThread *callbackThread_; 475490a39dSopenharmony_ci}; 485490a39dSopenharmony_ci} 495490a39dSopenharmony_ci} 505490a39dSopenharmony_ci#endif 51