Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/server.hpp> |
| 4 | #include "activation.hpp" |
| 5 | |
| 6 | namespace openpower |
| 7 | { |
| 8 | namespace software |
| 9 | { |
| 10 | namespace manager |
| 11 | { |
| 12 | |
| 13 | /** @class ItemUpdater |
| 14 | * @brief Manages the activation of the version items. |
| 15 | */ |
| 16 | class 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 */ |
Adriana Kobylak | 268616b | 2017-04-05 15:23:30 -0500 | [diff] [blame^] | 60 | std::map<std::string, std::unique_ptr<Activation>> activations; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 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 | |