1 /** 2 * Copyright © 2021 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "vpd.hpp" 18 19 #include "types.hpp" 20 #include "utility.hpp" 21 22 namespace phosphor::power::regulators 23 { 24 25 std::string DBusVPD::getValue(const std::string& inventoryPath, 26 const std::string& keyword) 27 { 28 std::string value{}; 29 30 // Get cached keywords for the inventory path 31 KeywordMap& cachedKeywords = cache[inventoryPath]; 32 33 // Check if the keyword value is already cached 34 auto it = cachedKeywords.find(keyword); 35 if (it != cachedKeywords.end()) 36 { 37 value = it->second; 38 } 39 else 40 { 41 // Get keyword value from D-Bus interface/property. The property name 42 // is normally the same as the VPD keyword name. However, the CCIN 43 // keyword is stored in the Model property. 44 std::string property{(keyword == "CCIN") ? "Model" : keyword}; 45 util::getProperty(ASSET_IFACE, property, inventoryPath, 46 INVENTORY_MGR_IFACE, bus, value); 47 48 // Cache keyword value 49 cachedKeywords[keyword] = value; 50 } 51 52 return value; 53 } 54 55 } // namespace phosphor::power::regulators 56