1 /*
2  * Copyright (c) 2021 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_EVENT_MULTIMODAL_MULTIMODAL_MANAGER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_MULTIMODAL_MULTIMODAL_MANAGER_H
18 
19 #include "base/memory/ace_type.h"
20 #include "core/event/multimodal/multimodal_scene.h"
21 #include "core/event/multimodal/multimodal_subscriber.h"
22 
23 namespace OHOS::Ace {
24 
25 class PipelineContext;
26 
27 class MultiModalManager final : public AceType {
28     DECLARE_ACE_TYPE(MultiModalManager, AceType)
29 
30 public:
31     MultiModalManager() = default;
32     ~MultiModalManager() override = default;
33 
34     void SetMultimodalSubscriber(const RefPtr<MultimodalSubscriber>& subscriber);
35     void OpenChannel(const RefPtr<PipelineContext>& context);
36 
37     RefPtr<MultiModalScene> GetMultiModalScene(int32_t pageId);
38     RefPtr<MultiModalScene> GetCurrentMultiModalScene();
39 
40     void DumpMultimodalScene();
41 
42     void PushActiveScene(int32_t newPageId);
43     void PopActiveScene(int32_t poppedPageId, int32_t incomingPageId);
44     void ReplaceActiveScene(int32_t newPageId, int32_t replaceId);
45     void RemoveInactiveScene(int32_t pageId);
46 
47 private:
48     void RemoveMultimodalScene(int32_t pageId);
49 
50     RefPtr<MultimodalSubscriber> subscriber_;
51     std::unordered_map<int32_t, RefPtr<MultiModalScene>> multiModalScenes_;
52     int32_t activeSceneId_ = -1;
53     bool isRegistered_ = false;
54 };
55 
56 } // namespace OHOS::Ace
57 
58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_MULTIMODAL_MULTIMODAL_MANAGER_H
59