blob: aab72cc9b2f56329c2cf6f1a5e1e42f57abc66e8 [file] [log] [blame]
Ratan Gupta1dc91782018-04-19 16:47:12 +05301#pragma once
Ratan Guptaa7ff3852018-11-16 14:05:57 +05302#include <experimental/filesystem>
Ratan Gupta1dc91782018-04-19 16:47:12 +05303
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
12namespace phosphor
13{
14namespace network
15{
16namespace snmp
17{
18
19class ConfManager;
20
21using Ifaces = sdbusplus::server::object::object<
22 sdbusplus::xyz::openbmc_project::Network::server::Client,
23 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
24
Ratan Guptaa7ff3852018-11-16 14:05:57 +053025using Id = size_t;
26
Ratan Gupta1dc91782018-04-19 16:47:12 +053027/** @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 */
32class 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 Gupta212f53e2018-04-30 17:28:05 +053052 /** @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 Guptaa7ff3852018-11-16 14:05:57 +053058 Ifaces(bus, objPath, true),
59 id(std::stol(std::experimental::filesystem::path(objPath).filename())),
60 parent(parent)
Ratan Gupta212f53e2018-04-30 17:28:05 +053061 {
62 }
63
Ratan Gupta1dc91782018-04-19 16:47:12 +053064 /** @brief Delete this d-bus object.
65 */
66 void delete_() override;
67
68 private:
Ratan Guptaa7ff3852018-11-16 14:05:57 +053069 /** Client ID. */
70 Id id;
Ratan Gupta1dc91782018-04-19 16:47:12 +053071 /** @brief Parent D-Bus Object. */
72 ConfManager &parent;
73};
74
75} // namespace snmp
76} // namespace network
77} // namespace phosphor