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 SYS_EVENT_SOURCE_H 17 #define SYS_EVENT_SOURCE_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "event_server.h" 24 #include "event_source.h" 25 #include "pipeline.h" 26 #include "plugin.h" 27 #include "platform_monitor.h" 28 29 namespace OHOS { 30 namespace HiviewDFX { 31 class SysEventSource; 32 33 class SysEventParser { 34 public: SysEventParser(PipelineEventProducer * producer)35 explicit SysEventParser(PipelineEventProducer* producer): pipeProducer(producer) {}; ~SysEventParser()36 ~SysEventParser() {}; 37 std::shared_ptr<PipelineEvent> Parser(const std::string& rawMsg) const; 38 private: 39 PipelineEventProducer* pipeProducer; 40 }; 41 42 class SysEventReceiver : public EventReceiver { 43 public: SysEventReceiver(SysEventSource & source)44 explicit SysEventReceiver(SysEventSource& source): eventSource(source) {}; ~SysEventReceiver()45 ~SysEventReceiver() override {}; 46 void HandlerEvent(const std::string& rawMsg) override; 47 private: 48 SysEventSource& eventSource; 49 }; 50 51 class SysEventSource : public EventSource { 52 public: SysEventSource()53 SysEventSource() {}; ~SysEventSource()54 ~SysEventSource() {}; 55 void OnLoad() override; 56 void OnUnload() override; 57 void StartEventSource() override; 58 void Recycle(PipelineEvent *event) override; 59 void PauseDispatch(std::weak_ptr<Plugin> plugin) override; 60 bool PublishPipelineEvent(std::shared_ptr<PipelineEvent> event); 61 62 private: 63 EventServer eventServer; 64 PlatformMonitor platformMonitor_; 65 }; 66 } // namespace HiviewDFX 67 } // namespace OHOS 68 #endif // SYS_EVENT_SOURCE_H