代码拉取完成,页面将自动刷新
#pragma once
#include <sdbusplus/server.hpp>
#include <unordered_map>
#include <vector>
namespace phosphor
{
namespace led
{
namespace utils
{
static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper";
static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
static constexpr auto proIntf = "org.freedesktop.DBus.Properties";
// The value of the property(type: variant, contains some basic types)
// Eg: uint8_t : dutyOn, uint16_t : Period, std::string : Name,
// std::vector<std::string> : endpoints, bool : Functional
using PropertyValue = std::variant<uint8_t, uint16_t, std::string,
std::vector<std::string>, bool>;
// The name of the property
using DbusProperty = std::string;
// The Map to constructs all properties values of the interface
using PropertyMap = std::unordered_map<DbusProperty, PropertyValue>;
/**
* @class DBusHandler
*
* Wrapper class to handle the D-Bus calls
*
* This class contains the APIs to handle the D-Bus calls.
*/
class DBusHandler
{
public:
/** @brief Get the bus connection. */
static auto& getBus()
{
static auto bus = sdbusplus::bus::new_default();
return bus;
}
/**
* @brief Get service name by the path and interface of the DBus.
*
* @param[in] path - D-Bus object path
* @param[in] interface - D-Bus Interface
*
* @return std::string - the D-Bus service name
*
*/
const std::string getService(const std::string& path,
const std::string& interface) const;
/** @brief Get All properties
*
* @param[in] objectPath - D-Bus object path
* @param[in] interface - D-Bus interface
*
* @return The Map to constructs all properties values
*
* @throw sdbusplus::exception_t when it fails
*/
const PropertyMap getAllProperties(const std::string& objectPath,
const std::string& interface) const;
/** @brief Get property(type: variant)
*
* @param[in] objectPath - D-Bus object path
* @param[in] interface - D-Bus interface
* @param[in] propertyName - D-Bus property name
*
* @return The value of the property(type: variant)
*
* @throw sdbusplus::exception_t when it fails
*/
const PropertyValue getProperty(const std::string& objectPath,
const std::string& interface,
const std::string& propertyName) const;
/** @brief Set D-Bus property
*
* @param[in] objectPath - D-Bus object path
* @param[in] interface - D-Bus interface
* @param[in] propertyName - D-Bus property name
* @param[in] value - The value to be set
*
* @throw sdbusplus::exception_t when it fails
*/
void setProperty(const std::string& objectPath,
const std::string& interface,
const std::string& propertyName,
const PropertyValue& value) const;
/** @brief Get sub tree paths by the path and interface of the DBus.
*
* @param[in] objectPath - D-Bus object path
* @param[in] interface - D-Bus object interface
*
* @return std::vector<std::string> vector of subtree paths
*/
const std::vector<std::string>
getSubTreePaths(const std::string& objectPath,
const std::string& interface);
};
} // namespace utils
} // namespace led
} // namespace phosphor
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。