• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
28 namespace OHOS {
29 namespace HiviewDFX {
30 class SysEventParser {
31 public:
SysEventParser(PipelineEventProducer * producer)32     explicit SysEventParser(PipelineEventProducer* producer): pipeProducer(producer) {};
~SysEventParser()33     ~SysEventParser() {};
34     std::shared_ptr<PipelineEvent> Parser(const std::string& rawMsg) const;
35 private:
36     PipelineEventProducer* pipeProducer;
37 };
38 
39 class SysEventReceiver : public EventReceiver {
40 public:
SysEventReceiver(EventSource & source)41     explicit SysEventReceiver(EventSource& source): eventSource(source) {};
~SysEventReceiver()42     ~SysEventReceiver() override {};
43     void HandlerEvent(const std::string& rawMsg) override;
44 private:
45     EventSource& eventSource;
46 };
47 
48 class SysEventSource : public EventSource {
49 public:
SysEventSource()50     SysEventSource() {};
~SysEventSource()51     ~SysEventSource() {};
52     void OnLoad() override;
53     void OnUnload() override;
54     void StartEventSource() override;
55     void Recycle(PipelineEvent *event) override;
56     void PauseDispatch(std::weak_ptr<Plugin> plugin) override;
57 
58 private:
59     EventServer eventServer;
60 };
61 } // namespace HiviewDFX
62 } // namespace OHOS
63 #endif // SYS_EVENT_SOURCE_H