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 HIVIEW_BASE_EVENT_EXPORT_ENGINE_H 17 #define HIVIEW_BASE_EVENT_EXPORT_ENGINE_H 18 19 #include <memory> 20 #include <mutex> 21 #include <vector> 22 #include <functional> 23 24 #include "export_base_task.h" 25 #include "export_config_manager.h" 26 #include "export_db_manager.h" 27 28 namespace OHOS { 29 namespace HiviewDFX { 30 class EventExportEngine { 31 public: 32 static EventExportEngine& GetInstance(); 33 34 public: 35 void Start(); 36 void Stop(); 37 38 private: 39 EventExportEngine(); 40 ~EventExportEngine(); 41 42 private: 43 void Init(); 44 void InitAndRunTasks(); 45 void HandleExportSwitchOn(const std::string& moduleName); 46 void HandleExportSwitchOff(const std::string& moduleName); 47 bool RegistSettingObserver(std::shared_ptr<ExportConfig> config); 48 void InitAndRunTask(std::shared_ptr<ExportConfig> config); 49 50 private: 51 bool isTaskRunning_ = false; 52 std::shared_ptr<ExportDbManager> dbMgr_ = nullptr; 53 std::mutex mgrMutex_; 54 std::vector<std::shared_ptr<ExportConfig>> configs_; 55 }; 56 } // namespace HiviewDFX 57 } // namespace OHOS 58 59 #endif // HIVIEW_BASE_EVENT_EXPORT_ENGINE_H