1 /* 2 * Copyright (c) 2021-2025 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 "event_source.h" 16 #include "hiview_logger.h" 17 namespace OHOS { 18 namespace HiviewDFX { 19 DEFINE_LOG_TAG("HiView-EventSource"); PublishPipelineEvent(std::shared_ptr<PipelineEvent> event)20bool EventSource::PublishPipelineEvent(std::shared_ptr<PipelineEvent> event) 21 { 22 HIVIEW_LOGD("EventSource PublishPipelineEvent"); 23 if (event == nullptr) { 24 return false; 25 } 26 27 for (auto& pipeline : listeners_) { 28 if ((pipeline != nullptr) && (pipeline->CanProcessEvent(event))) { 29 // one event can only be processed by on pipeline 30 pipeline->ProcessEvent(event); 31 return true; 32 } 33 } 34 return false; 35 } 36 AddPipeline(std::shared_ptr<Pipeline> pipeline)37void EventSource::AddPipeline(std::shared_ptr<Pipeline> pipeline) 38 { 39 if (pipeline == nullptr) { 40 HIVIEW_LOGW("Add nullptr pipeline to %{public}s.", GetName().c_str()); 41 return; 42 } 43 HIVIEW_LOGD("EventSource add pipeline %{public}s.", pipeline->GetName().c_str()); 44 listeners_.push_back(pipeline); 45 } 46 StartEventSource()47void EventSource::StartEventSource() 48 { 49 // default non-implement 50 } 51 } // namespace HiviewDFX 52 } // namespace OHOS 53