1 #pragma once
2 
3 #include <sdbusplus/server.hpp>
4 #include "activation.hpp"
5 
6 namespace phosphor
7 {
8 namespace software
9 {
10 namespace updater
11 {
12 
13 namespace MatchRules = sdbusplus::bus::match::rules;
14 
15 /** @class ItemUpdater
16  *  @brief Manages the activation of the BMC version items.
17  */
18 class 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,
36                             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         };
44 
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
50          */
51         void createActivation(sdbusplus::message::message& msg);
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::bus::match_t versionMatch;
62 
63 };
64 
65 
66 
67 } // namespace updater
68 } // namespace software
69 } // namespace phosphor
70