• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "enabled_comps_dump.h"
17 
18 namespace OHOS {
19 namespace DistributedHardware {
20 IMPLEMENT_SINGLE_INSTANCE(EnabledCompsDump);
21 
DumpEnabledComp(const std::string & networkId,const DHType dhType,const std::string & dhId)22 void EnabledCompsDump::DumpEnabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId)
23 {
24     HidumpCompInfo info(networkId, dhType, dhId);
25 
26     std::lock_guard<std::mutex> lock(compInfosMutex_);
27     compInfoSet_.emplace(info);
28 }
29 
DumpDisabledComp(const std::string & networkId,const DHType dhType,const std::string & dhId)30 void EnabledCompsDump::DumpDisabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId)
31 {
32     HidumpCompInfo info(networkId, dhType, dhId);
33 
34     std::lock_guard<std::mutex> lock(compInfosMutex_);
35     auto it = compInfoSet_.find(info);
36     if (it != compInfoSet_.end()) {
37         compInfoSet_.erase(it);
38     }
39 }
40 
Dump(std::set<HidumpCompInfo> & compInfoSet)41 void EnabledCompsDump::Dump(std::set<HidumpCompInfo> &compInfoSet)
42 {
43     std::lock_guard<std::mutex> lock(compInfosMutex_);
44     compInfoSet = compInfoSet_;
45 }
46 } // namespace DistributedHardware
47 } // namespace OHOS
48