1 #include "custom_dbus.hpp"
2
3 namespace pldm
4 {
5 namespace dbus
6 {
setLocationCode(const std::string & path,std::string value)7 void CustomDBus::setLocationCode(const std::string& path, std::string value)
8 {
9 if (!location.contains(path))
10 {
11 location.emplace(path,
12 std::make_unique<LocationIntf>(
13 pldm::utils::DBusHandler::getBus(), path.c_str()));
14 }
15
16 location.at(path)->locationCode(value);
17 }
18
19 std::optional<std::string>
getLocationCode(const std::string & path) const20 CustomDBus::getLocationCode(const std::string& path) const
21 {
22 if (location.contains(path))
23 {
24 return location.at(path)->locationCode();
25 }
26
27 return std::nullopt;
28 }
29
implementCpuCoreInterface(const std::string & path)30 void CustomDBus::implementCpuCoreInterface(const std::string& path)
31 {
32 if (!cpuCore.contains(path))
33 {
34 cpuCore.emplace(path, std::make_unique<CPUCore>(
35 pldm::utils::DBusHandler::getBus(), path));
36 }
37 }
38
setMicroCode(const std::string & path,uint32_t value)39 void CustomDBus::setMicroCode(const std::string& path, uint32_t value)
40 {
41 if (!cpuCore.contains(path))
42 {
43 cpuCore.emplace(path, std::make_unique<CPUCore>(
44 pldm::utils::DBusHandler::getBus(), path));
45 }
46 cpuCore.at(path)->microcode(value);
47 }
48
getMicroCode(const std::string & path) const49 std::optional<uint32_t> CustomDBus::getMicroCode(const std::string& path) const
50 {
51 if (cpuCore.contains(path))
52 {
53 return cpuCore.at(path)->microcode();
54 }
55
56 return std::nullopt;
57 }
58 } // namespace dbus
59 } // namespace pldm
60