blob: a854a62bc6b979676a81f55ab1660cb4c8385a81 [file] [log] [blame]
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05001#pragma once
2
3#include <sdbusplus/server.hpp>
4#include "activation.hpp"
5
6namespace openpower
7{
8namespace software
9{
10namespace manager
11{
12
13/** @class ItemUpdater
14 * @brief Manages the activation of the version items.
15 */
16class ItemUpdater
17{
18 public:
19 ItemUpdater() = delete;
20 ~ItemUpdater() = default;
21 ItemUpdater(const ItemUpdater&) = delete;
22 ItemUpdater& operator=(const ItemUpdater&) = delete;
23 ItemUpdater(ItemUpdater&&) = delete;
24 ItemUpdater& operator=(ItemUpdater&&) = delete;
25
26 /** @brief Constructs ItemUpdater
27 *
28 * @param[in] bus - The Dbus bus object
29 */
30 ItemUpdater(sdbusplus::bus::bus& bus) :
31 busItem(bus),
32 versionMatch(
33 bus,
34 "type='signal',"
35 "member='InterfacesAdded',"
36 "path='/xyz/openbmc_project/software',"
37 "interface='org.freedesktop.DBus.ObjectManager'",
38 createActivation,
39 this)
40 {
41 }
42
43 private:
44 /** @brief Callback function for Software.Version match.
45 * @details Creates an Activation dbus object.
46 *
47 * @param[in] msg - Data associated with subscribed signal
48 * @param[in] userData - Pointer to this object instance
49 * @param[out] retError - Required param
50 */
51 static int createActivation(sd_bus_message* msg,
52 void* userData,
53 sd_bus_error* retError);
54
55 /** @brief Persistent sdbusplus DBus bus connection. */
56 sdbusplus::bus::bus& busItem;
57
58 /** @brief Persistent map of Activation dbus objects and their
59 * version id */
60 std::map<uint32_t, std::unique_ptr<Activation>> activations;
61
62 /** @brief sdbusplus signal match for Software.Version */
63 sdbusplus::server::match::match versionMatch;
64};
65
66} // namespace manager
67} // namespace software
68} // namespace openpower
69