blob: 1a3622654aea51d3c809a194a2d94b4a48cf2cf2 [file] [log] [blame]
Gunnar Millsec1b41c2017-05-02 12:20:36 -05001#pragma once
2
3#include <sdbusplus/server.hpp>
4#include "activation.hpp"
5
6namespace phosphor
7{
8namespace software
9{
10namespace updater
11{
12
13/** @class ItemUpdater
14 * @brief Manages the activation of the BMC 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 bus(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 private:
42 /** @brief Callback function for Software.Version match.
43 * @details Creates an Activation dbus object.
44 *
45 * @param[in] msg - Data associated with subscribed signal
46 * @param[in] userData - Pointer to this object instance
47 * @param[out] retError - Required param
48 */
49 static int createActivation(sd_bus_message* msg,
50 void* userData,
51 sd_bus_error* retError);
52
53 /** @brief Persistent sdbusplus DBus bus connection. */
54 sdbusplus::bus::bus& bus;
55
56 /** @brief Persistent map of Activation dbus objects and their
57 * version id */
58 std::map<std::string, std::unique_ptr<Activation>> activations;
59
60 /** @brief sdbusplus signal match for Software.Version */
61 sdbusplus::server::match::match versionMatch;
62
63};
64
65
66
67} // namespace updater
68} // namespace software
69} // namespace phosphor