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 #include "plugin_example.h" 16 17 #include "event_loop.h" 18 #include "plugin_factory.h" 19 20 namespace OHOS { 21 namespace HiviewDFX { 22 REGISTER(PluginExample); OnEvent(std::shared_ptr<Event> & event)23bool PluginExample::OnEvent(std::shared_ptr<Event>& event) 24 { 25 if (event != nullptr && event->IsPipelineEvent()) { 26 printf(" Repack in plugin Example.\n"); 27 Event::Repack<PluginExampleEvent, PipelineEvent>(event); 28 return true; 29 } 30 return false; 31 }; 32 OnLoad()33void PluginExample::OnLoad() 34 { 35 printf(" PluginExample OnLoad.\n"); 36 auto looper = std::make_shared<EventLoop>("PluginExample"); 37 if (looper != nullptr) { 38 looper->StartLoop(); 39 BindWorkLoop(looper); 40 printf(" PluginExample BindWorkLoop.\n"); 41 } 42 } 43 } // namespace HiviewDFX 44 } // namespace OHOS 45