1 /* 2 * Copyright (c) 2023 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 #ifndef INTELL_VOICE_TRIGGER_MANAGER_H 16 #define INTELL_VOICE_TRIGGER_MANAGER_H 17 18 #include <map> 19 #include <memory> 20 #include "trigger_base_type.h" 21 #include "trigger_service.h" 22 #include "trigger_detector.h" 23 #include "i_intell_voice_trigger_detector_callback.h" 24 25 namespace OHOS { 26 namespace IntellVoiceTrigger { 27 class TriggerManager { 28 public: 29 ~TriggerManager(); 30 static std::shared_ptr<TriggerManager> GetInstance(); 31 32 void UpdateModel(std::shared_ptr<GenericTriggerModel> model); 33 void DeleteModel(int32_t uuid); 34 std::shared_ptr<GenericTriggerModel> GetModel(int32_t uuid); 35 std::shared_ptr<TriggerDetector> CreateTriggerDetector( 36 int32_t uuid, std::shared_ptr<IIntellVoiceTriggerDetectorCallback> callback); 37 void ReleaseTriggerDetector(int32_t uuid); 38 39 private: 40 explicit TriggerManager(); 41 42 private: 43 std::map<int32_t, std::shared_ptr<TriggerDetector>> detectors_; 44 std::shared_ptr<TriggerService> service_; 45 46 static std::mutex instanceMutex_; 47 static std::shared_ptr<TriggerManager> instance_; 48 }; 49 } // namespace IntellVoiceTrigger 50 } // namespace OHOS 51 #endif