blob: 5fc71e08df3bc1244bcbb3bc76aafcc7197d742a [file] [log] [blame]
Deepak Kodihalli867f7aa2017-02-27 00:22:50 -06001#pragma once
2#include <tuple>
3#include <systemd/sd-bus.h>
4#include <sdbusplus/server.hpp>
5
6namespace sdbusplus
7{
8namespace org
9{
10namespace openbmc
11{
12namespace server
13{
14
15class Associations
16{
17 public:
18 /* Define all of the basic class operations:
19 * Not allowed:
20 * - Default constructor to avoid nullptrs.
21 * - Copy operations due to internal unique_ptr.
22 * - Move operations due to 'this' being registered as the
23 * 'context' with sdbus.
24 * Allowed:
25 * - Destructor.
26 */
27 Associations() = delete;
28 Associations(const Associations&) = delete;
29 Associations& operator=(const Associations&) = delete;
30 Associations(Associations&&) = delete;
31 Associations& operator=(Associations&&) = delete;
32 virtual ~Associations() = default;
33
34 /** @brief Constructor to put object onto bus at a dbus path.
35 * @param[in] bus - Bus to attach to.
36 * @param[in] path - Path to attach at.
37 */
38 Associations(bus::bus& bus, const char* path);
39
40
41 using PropertiesVariant = sdbusplus::message::variant<
42 std::vector<std::tuple<std::string, std::string, std::string>>>;
43
44 /** @brief Constructor to initialize the object from a map of
45 * properties.
46 *
47 * @param[in] bus - Bus to attach to.
48 * @param[in] path - Path to attach at.
Gunnar Millsdeae3ca2017-10-25 17:22:22 -050049 * @param[in] vals - Map of property name to value for initialization.
Deepak Kodihalli867f7aa2017-02-27 00:22:50 -060050 */
51 Associations(bus::bus& bus, const char* path,
52 const std::map<std::string, PropertiesVariant>& vals);
53
54
55
56 /** Get value of associations */
57 virtual std::vector<std::tuple<std::string, std::string, std::string>> associations() const;
58 /** Set value of associations */
59 virtual std::vector<std::tuple<std::string, std::string, std::string>> associations(std::vector<std::tuple<std::string, std::string, std::string>> value);
60
61 /** @brief Sets a property by name.
62 * @param[in] name - A string representation of the property name.
63 * @param[in] val - A variant containing the value to set.
64 */
65 void setPropertyByName(const std::string& name,
66 const PropertiesVariant& val);
67
68 /** @brief Gets a property by name.
69 * @param[in] name - A string representation of the property name.
70 * @return - A variant containing the value of the property.
71 */
72 PropertiesVariant getPropertyByName(const std::string& name);
73
74
75 private:
76
77 /** @brief sd-bus callback for get-property 'associations' */
78 static int _callback_get_associations(
79 sd_bus*, const char*, const char*, const char*,
80 sd_bus_message*, void*, sd_bus_error*);
81 /** @brief sd-bus callback for set-property 'associations' */
82 static int _callback_set_associations(
83 sd_bus*, const char*, const char*, const char*,
84 sd_bus_message*, void*, sd_bus_error*);
85
86
87 static constexpr auto _interface = "org.openbmc.Associations";
88 static const vtable::vtable_t _vtable[];
89 sdbusplus::server::interface::interface
90 _org_openbmc_Associations_interface;
91
92 std::vector<std::tuple<std::string, std::string, std::string>> _associations{};
93
94};
95
96
97} // namespace server
98} // namespace openbmc
99} // namespace org
100} // namespace sdbusplus
101