blob: e35a7b37f3eb4a916c9c38b0f880ecc00451ec5e [file] [log] [blame]
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06001#pragma once
2#include <tuple>
3#include <systemd/sd-bus.h>
4#include <sdbusplus/server.hpp>
5
6namespace sdbusplus
7{
8namespace xyz
9{
10namespace openbmc_project
11{
12namespace Logging
13{
14namespace server
15{
16
17class Entry
18{
19 public:
20 /* Define all of the basic class operations:
21 * Not allowed:
22 * - Default constructor to avoid nullptrs.
23 * - Copy operations due to internal unique_ptr.
24 * - Move operations due to 'this' being registered as the
25 * 'context' with sdbus.
26 * Allowed:
27 * - Destructor.
28 */
29 Entry() = delete;
30 Entry(const Entry&) = delete;
31 Entry& operator=(const Entry&) = delete;
32 Entry(Entry&&) = delete;
33 Entry& operator=(Entry&&) = delete;
34 virtual ~Entry() = default;
35
36 /** @brief Constructor to put object onto bus at a dbus path.
37 * @param[in] bus - Bus to attach to.
38 * @param[in] path - Path to attach at.
39 */
40 Entry(bus::bus& bus, const char* path);
41
42 enum class Level
43 {
44 Emergency,
45 Alert,
46 Critical,
47 Error,
48 Warning,
49 Notice,
50 Informational,
51 Debug,
52 };
53
54
55
56 /** Get value of Id */
57 virtual uint32_t id() const;
58 /** Set value of Id */
59 virtual uint32_t id(uint32_t value);
60 /** Get value of Severity */
61 virtual Level severity() const;
62 /** Set value of Severity */
63 virtual Level severity(Level value);
64 /** Get value of Message */
65 virtual std::string message() const;
66 /** Set value of Message */
67 virtual std::string message(std::string value);
68 /** Get value of AdditionalData */
69 virtual std::vector<std::string> additionalData() const;
70 /** Set value of AdditionalData */
71 virtual std::vector<std::string> additionalData(std::vector<std::string> value);
72
73 /** @brief Convert a string to an appropriate enum value.
74 * @param[in] s - The string to convert in the form of
75 * "xyz.openbmc_project.Logging.Entry.<value name>"
76 * @return - The enum value.
77 */
78 static Level convertLevelFromString(std::string& s);
79
80 private:
81
82 /** @brief sd-bus callback for get-property 'Id' */
83 static int _callback_get_Id(
84 sd_bus*, const char*, const char*, const char*,
85 sd_bus_message*, void*, sd_bus_error*);
86 /** @brief sd-bus callback for set-property 'Id' */
87 static int _callback_set_Id(
88 sd_bus*, const char*, const char*, const char*,
89 sd_bus_message*, void*, sd_bus_error*);
90
91 /** @brief sd-bus callback for get-property 'Severity' */
92 static int _callback_get_Severity(
93 sd_bus*, const char*, const char*, const char*,
94 sd_bus_message*, void*, sd_bus_error*);
95 /** @brief sd-bus callback for set-property 'Severity' */
96 static int _callback_set_Severity(
97 sd_bus*, const char*, const char*, const char*,
98 sd_bus_message*, void*, sd_bus_error*);
99
100 /** @brief sd-bus callback for get-property 'Message' */
101 static int _callback_get_Message(
102 sd_bus*, const char*, const char*, const char*,
103 sd_bus_message*, void*, sd_bus_error*);
104 /** @brief sd-bus callback for set-property 'Message' */
105 static int _callback_set_Message(
106 sd_bus*, const char*, const char*, const char*,
107 sd_bus_message*, void*, sd_bus_error*);
108
109 /** @brief sd-bus callback for get-property 'AdditionalData' */
110 static int _callback_get_AdditionalData(
111 sd_bus*, const char*, const char*, const char*,
112 sd_bus_message*, void*, sd_bus_error*);
113 /** @brief sd-bus callback for set-property 'AdditionalData' */
114 static int _callback_set_AdditionalData(
115 sd_bus*, const char*, const char*, const char*,
116 sd_bus_message*, void*, sd_bus_error*);
117
118
119 static constexpr auto _interface = "xyz.openbmc_project.Logging.Entry";
120 static const vtable::vtable_t _vtable[];
121 sdbusplus::server::interface::interface
122 _xyz_openbmc_project_Logging_Entry_interface;
123
124 uint32_t _id{};
125 Level _severity{};
126 std::string _message{};
127 std::vector<std::string> _additionalData{};
128
129};
130
131/* Specialization of sdbusplus::server::bindings::details::convertForMessage
132 * for enum-type Entry::Level.
133 *
134 * This converts from the enum to a constant c-string representing the enum.
135 *
136 * @param[in] e - Enum value to convert.
137 * @return C-string representing the name for the enum value.
138 */
139std::string convertForMessage(Entry::Level e);
140
141} // namespace server
142} // namespace Logging
143} // namespace openbmc_project
144} // namespace xyz
145} // namespace sdbusplus
146