Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 1 | #pragma once |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 2 | #include <experimental/filesystem> |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 3 | |
| 4 | #include "xyz/openbmc_project/Network/Client/server.hpp" |
| 5 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
| 6 | |
| 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/object.hpp> |
| 9 | |
| 10 | #include <string> |
| 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | namespace snmp |
| 17 | { |
| 18 | |
| 19 | class ConfManager; |
| 20 | |
| 21 | using Ifaces = sdbusplus::server::object::object< |
| 22 | sdbusplus::xyz::openbmc_project::Network::server::Client, |
| 23 | sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
| 24 | |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 25 | using Id = size_t; |
| 26 | |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 27 | /** @class Client |
| 28 | * @brief represents the snmp client configuration |
| 29 | * @details A concrete implementation for the |
| 30 | * xyz.openbmc_project.Network.Client Dbus interface. |
| 31 | */ |
| 32 | class Client : public Ifaces |
| 33 | { |
| 34 | public: |
| 35 | Client() = delete; |
| 36 | Client(const Client &) = delete; |
| 37 | Client &operator=(const Client &) = delete; |
| 38 | Client(Client &&) = delete; |
| 39 | Client &operator=(Client &&) = delete; |
| 40 | virtual ~Client() = default; |
| 41 | |
| 42 | /** @brief Constructor to put object onto bus at a dbus path. |
| 43 | * @param[in] bus - Bus to attach to. |
| 44 | * @param[in] objPath - Path to attach at. |
| 45 | * @param[in] parent - Parent D-bus Object. |
| 46 | * @param[in] address - IPaddress/Hostname. |
| 47 | * @param[in] port - network port. |
| 48 | */ |
| 49 | Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent, |
| 50 | const std::string &address, uint16_t port); |
| 51 | |
Ratan Gupta | 212f53e | 2018-04-30 17:28:05 +0530 | [diff] [blame] | 52 | /** @brief Constructor to put object onto bus at a dbus path. |
| 53 | * @param[in] bus - Bus to attach to. |
| 54 | * @param[in] objPath - Path to attach at. |
| 55 | * @param[in] parent - Parent D-bus Object. |
| 56 | */ |
| 57 | Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent) : |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 58 | Ifaces(bus, objPath, true), |
| 59 | id(std::stol(std::experimental::filesystem::path(objPath).filename())), |
| 60 | parent(parent) |
Ratan Gupta | 212f53e | 2018-04-30 17:28:05 +0530 | [diff] [blame] | 61 | { |
| 62 | } |
| 63 | |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 64 | /** @brief Delete this d-bus object. |
| 65 | */ |
| 66 | void delete_() override; |
| 67 | |
| 68 | private: |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 69 | /** Client ID. */ |
| 70 | Id id; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 71 | /** @brief Parent D-Bus Object. */ |
| 72 | ConfManager &parent; |
| 73 | }; |
| 74 | |
| 75 | } // namespace snmp |
| 76 | } // namespace network |
| 77 | } // namespace phosphor |