• 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 #include "event_processor_example3.h"
17 
18 #include "pipeline.h"
19 #include "plugin_factory.h"
20 
21 namespace OHOS {
22 namespace HiviewDFX {
23 REGISTER_PROXY(EventProcessorExample3);
EventProcessorExample3()24 EventProcessorExample3::EventProcessorExample3()
25 {
26     printf("EventProcessorExample3::EventProcessorExample3()\n");
27     EventSourceExample::count.insert("EventProcessorExample3");
28 }
29 
~EventProcessorExample3()30 EventProcessorExample3::~EventProcessorExample3()
31 {
32     printf("EventProcessorExample3::~EventProcessorExample3()\n");
33     EventSourceExample::count.erase("EventProcessorExample3");
34 }
35 
CanProcessEvent(std::shared_ptr<Event> event)36 bool EventProcessorExample3::CanProcessEvent(std::shared_ptr<Event> event)
37 {
38     printf("EventProcessorExample3 CanProcessEvent: %d.\n", event->eventId_);
39     if (event->eventId_ == EventSourceExample::PIPELINE_EVENT_ID_CCC) {
40         printf("EventProcessorExample3 CanProcessEvent true.\n");
41         return true;
42     }
43     return false;
44 }
45 
OnEvent(std::shared_ptr<Event> & event)46 bool EventProcessorExample3::OnEvent(std::shared_ptr<Event>& event)
47 {
48     printf("EventProcessorExample3 OnEvent 0 tid:%d sender:%s.\n", gettid(), event->sender_.c_str());
49     if (event->eventId_ == EventSourceExample::PIPELINE_EVENT_ID_BBB) {
50         printf("EventProcessorExample3 process bbb event.\n");
51     }
52 
53     if (event->eventId_ == EventSourceExample::PIPELINE_EVENT_ID_AAA) {
54         printf("EventProcessorExample3 process aaa event.\n");
55     }
56 
57     if (GetHiviewContext() != nullptr) {
58         GetHiviewContext()->SetHiviewProperty("EPE3_OnEvent", "received : " + event->eventName_, true);
59     }
60     event->SetValue("EventProcessorExample3", "Done");
61     return true;
62 }
63 
OnLoad()64 void EventProcessorExample3::OnLoad()
65 {
66     SetVersion("EventProcessorExample3.0");
67     printf("EventProcessorExample3 OnLoad\n");
68 }
69 
OnUnload()70 void EventProcessorExample3::OnUnload()
71 {
72     printf("EventProcessorExample3 OnUnload \n");
73 }
74 } // namespace HiviewDFX
75 } // namespace OHOS