1 /* 2 * Copyright (c) 2022 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 OHOS_DISTRIBUTED_ENABLED_COMPS_DUMP_H 17 #define OHOS_DISTRIBUTED_ENABLED_COMPS_DUMP_H 18 19 #include <mutex> 20 #include <set> 21 #include <string> 22 23 #include "device_type.h" 24 #include "single_instance.h" 25 26 namespace OHOS { 27 namespace DistributedHardware { 28 struct HidumpCompInfo { 29 std::string networkId_; 30 std::string dhId_; 31 DHType dhType_; 32 HidumpCompInfoHidumpCompInfo33 HidumpCompInfo(std::string networkId, DHType dhType, std::string dhId) 34 : networkId_(networkId), dhId_(dhId), dhType_(dhType) {} 35 36 bool operator < (const HidumpCompInfo &other) const 37 { 38 return (((this->networkId_ == other.networkId_) && (this->dhId_ < other.dhId_)) || 39 (this->networkId_ < other.networkId_)); 40 } 41 }; 42 43 class EnabledCompsDump { 44 DECLARE_SINGLE_INSTANCE_BASE(EnabledCompsDump); 45 public: 46 void DumpEnabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId); 47 void DumpDisabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId); 48 49 void Dump(std::set<HidumpCompInfo> &compInfoSet); 50 51 private: 52 explicit EnabledCompsDump() = default; 53 ~EnabledCompsDump() = default; 54 55 private: 56 std::mutex compInfosMutex_; 57 std::set<HidumpCompInfo> compInfoSet_; 58 }; 59 } // namespace DistributedHardware 60 } // namespace OHOS 61 #endif