blob: e9bea6f1ceb09ecb1dbed2aff0990391dbe5590b [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
Patrick Williamse75d10f2017-05-30 16:56:32 -050013namespace MatchRules = sdbusplus::bus::match::rules;
14
Gunnar Millsec1b41c2017-05-02 12:20:36 -050015/** @class ItemUpdater
16 * @brief Manages the activation of the BMC version items.
17 */
18class ItemUpdater
19{
20 public:
21 ItemUpdater() = delete;
22 ~ItemUpdater() = default;
23 ItemUpdater(const ItemUpdater&) = delete;
24 ItemUpdater& operator=(const ItemUpdater&) = delete;
25 ItemUpdater(ItemUpdater&&) = delete;
26 ItemUpdater& operator=(ItemUpdater&&) = delete;
27
28 /** @brief Constructs ItemUpdater
29 *
30 * @param[in] bus - The Dbus bus object
31 */
32 ItemUpdater(sdbusplus::bus::bus& bus) :
33 bus(bus),
34 versionMatch(
35 bus,
Patrick Williamse75d10f2017-05-30 16:56:32 -050036 MatchRules::interfacesAdded() +
37 MatchRules::path("/xyz/openbmc_project/software"),
38 std::bind(
39 std::mem_fn(&ItemUpdater::createActivation),
40 this,
41 std::placeholders::_1))
42 {
43 };
Gunnar Millsec1b41c2017-05-02 12:20:36 -050044
45 private:
46 /** @brief Callback function for Software.Version match.
47 * @details Creates an Activation dbus object.
48 *
49 * @param[in] msg - Data associated with subscribed signal
Gunnar Millsec1b41c2017-05-02 12:20:36 -050050 */
Patrick Williamse75d10f2017-05-30 16:56:32 -050051 void createActivation(sdbusplus::message::message& msg);
Gunnar Millsec1b41c2017-05-02 12:20:36 -050052
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 */
Patrick Williamse75d10f2017-05-30 16:56:32 -050061 sdbusplus::bus::match_t versionMatch;
Gunnar Millsec1b41c2017-05-02 12:20:36 -050062
63};
64
65
66
67} // namespace updater
68} // namespace software
69} // namespace phosphor