• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 I_COMMON_EVENT_ADAPTER_H
17 #define I_COMMON_EVENT_ADAPTER_H
18 
19 #include <functional>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "common_event_manager.h"
25 #include "common_event_support.h"
26 
27 namespace OHOS {
28 namespace Msdp {
29 namespace DeviceStatus {
30 using CommonEventHandleType = std::function<void(const std::string &event)>;
31 
32 class ICommonEventObserver : public OHOS::EventFwk::CommonEventSubscriber {
33 public:
ICommonEventObserver(const OHOS::EventFwk::CommonEventSubscribeInfo & info)34     explicit ICommonEventObserver(const OHOS::EventFwk::CommonEventSubscribeInfo &info)
35         : CommonEventSubscriber(info) {}
36     virtual ~ICommonEventObserver() = default;
37 
38     void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &event) override = 0;
39 };
40 
41 class ICommonEventAdapter {
42 public:
43     ICommonEventAdapter() = default;
44     virtual ~ICommonEventAdapter() = default;
45 
46     virtual int32_t AddObserver(std::shared_ptr<ICommonEventObserver> observer) = 0;
47     virtual int32_t RemoveObserver(std::shared_ptr<ICommonEventObserver> observer) = 0;
48 };
49 } // namespace DeviceStatus
50 } // namespace Msdp
51 } // namespace OHOS
52 #endif // I_COMMON_EVENT_ADAPTER_H
53