summaryrefslogtreecommitdiffstats
path: root/xyz/openbmc_project/Led/Physical/server.hpp
blob: 2269f428682e2224b6afcdd50af9f531d217e8ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
#include <tuple>
#include <systemd/sd-bus.h>
#include <sdbusplus/server.hpp>

namespace sdbusplus
{
namespace xyz
{
namespace openbmc_project
{
namespace Led
{
namespace server
{

class Physical
{
    public:
        /* Define all of the basic class operations:
         *     Not allowed:
         *         - Default constructor to avoid nullptrs.
         *         - Copy operations due to internal unique_ptr.
         *     Allowed:
         *         - Move operations.
         *         - Destructor.
         */
        Physical() = delete;
        Physical(const Physical&) = delete;
        Physical& operator=(const Physical&) = delete;
        Physical(Physical&&) = default;
        Physical& operator=(Physical&&) = default;
        virtual ~Physical() = default;

        /** @brief Constructor to put object onto bus at a dbus path.
         *  @param[in] bus - Bus to attach to.
         *  @param[in] path - Path to attach at.
         */
        Physical(bus::bus& bus, const char* path);

        enum class Action
        {
            Off,
            On,
            Blink,
        };
        enum class Palette
        {
            Unknown,
            Red,
            Green,
            Blue,
            Yellow,
        };



        /** Get value of State */
        virtual Action state() const;
        /** Set value of State */
        virtual Action state(Action value);
        /** Get value of DutyOn */
        virtual uint8_t dutyOn() const;
        /** Set value of DutyOn */
        virtual uint8_t dutyOn(uint8_t value);
        /** Get value of Color */
        virtual Palette color() const;
        /** Set value of Color */
        virtual Palette color(Palette value);

    /** @brief Convert a string to an appropriate enum value.
     *  @param[in] s - The string to convert in the form of
     *                 "xyz.openbmc_project.Led.Physical.<value name>"
     *  @return - The enum value.
     */
    static Action convertActionFromString(std::string& s);
    /** @brief Convert a string to an appropriate enum value.
     *  @param[in] s - The string to convert in the form of
     *                 "xyz.openbmc_project.Led.Physical.<value name>"
     *  @return - The enum value.
     */
    static Palette convertPaletteFromString(std::string& s);

    private:

        /** @brief sd-bus callback for get-property 'State' */
        static int _callback_get_State(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);
        /** @brief sd-bus callback for set-property 'State' */
        static int _callback_set_State(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);

        /** @brief sd-bus callback for get-property 'DutyOn' */
        static int _callback_get_DutyOn(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);
        /** @brief sd-bus callback for set-property 'DutyOn' */
        static int _callback_set_DutyOn(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);

        /** @brief sd-bus callback for get-property 'Color' */
        static int _callback_get_Color(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);
        /** @brief sd-bus callback for set-property 'Color' */
        static int _callback_set_Color(
            sd_bus*, const char*, const char*, const char*,
            sd_bus_message*, void*, sd_bus_error*);


        static constexpr auto _interface = "xyz.openbmc_project.Led.Physical";
        static const vtable::vtable_t _vtable[];
        sdbusplus::server::interface::interface
                _xyz_openbmc_project_Led_Physical_interface;

        Action _state = Action::Off;
        uint8_t _dutyOn = 50;
        Palette _color = Palette::Unknown;

};

/* Specialization of sdbusplus::server::bindings::details::convertForMessage
 * for enum-type Physical::Action.
 *
 * This converts from the enum to a constant c-string representing the enum.
 *
 * @param[in] e - Enum value to convert.
 * @return C-string representing the name for the enum value.
 */
std::string convertForMessage(Physical::Action e);
/* Specialization of sdbusplus::server::bindings::details::convertForMessage
 * for enum-type Physical::Palette.
 *
 * This converts from the enum to a constant c-string representing the enum.
 *
 * @param[in] e - Enum value to convert.
 * @return C-string representing the name for the enum value.
 */
std::string convertForMessage(Physical::Palette e);

} // namespace server
} // namespace Led
} // namespace openbmc_project
} // namespace xyz
} // namespace sdbusplus

OpenPOWER on IntegriCloud