1 /* 2 * Copyright (c) 2021-2022 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 HISYSEVENT_MANAGER_H 17 #define HISYSEVENT_MANAGER_H 18 19 #include <string> 20 #include <unordered_map> 21 #include <vector> 22 23 #include "hisysevent_base_listener.h" 24 #include "hisysevent_listener.h" 25 #include "hisysevent_query_callback.h" 26 #include "hisysevent_rules.h" 27 28 namespace OHOS { 29 namespace HiviewDFX { 30 class HiSysEventManager { 31 public: 32 HiSysEventManager() = default; ~HiSysEventManager()33 ~HiSysEventManager() {} 34 35 public: 36 static int32_t AddListener(std::shared_ptr<HiSysEventListener> listener, 37 std::vector<ListenerRule>& rules); 38 static int32_t RemoveListener(std::shared_ptr<HiSysEventListener> listener); 39 static int32_t Query(struct QueryArg& arg, std::vector<QueryRule>& rules, 40 std::shared_ptr<HiSysEventQueryCallback> callback); 41 static int32_t SetDebugMode(std::shared_ptr<HiSysEventListener> listener, bool mode); 42 43 private: 44 static std::unordered_map<std::shared_ptr<HiSysEventListener>, 45 std::shared_ptr<HiSysEventBaseListener>> listenerToBaseMap; 46 }; 47 } // namespace HiviewDFX 48 } // namespace OHOS 49 50 #endif // HISYSEVENT_MANAGER_H 51 52