blob: 835241fd1d37ec27607a05b2d30744ec67dcb3f5 [file] [log] [blame]
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05001#pragma once
2
3#include <string>
4#include <vector>
5#include <sdbusplus/bus.hpp>
6#include <sdbusplus/server/object.hpp>
7#include "org/open_power/OCC/PassThrough/server.hpp"
8#include "config.h"
9
10namespace open_power
11{
12namespace occ
13{
14namespace pass_through
15{
16
17/** @brief Make occ pass-through d-bus object pathname
18 * @param[in] occ - occ name
19 * @returns occ pass-through path
20 */
21inline auto object(const std::string& occ)
22{
23 return std::string(OCC_PASS_THROUGH_ROOT) +
24 '/' +
25 occ;
26}
27
28/** @brief Put occ pass through objects on the bus
29 */
30void run();
31
32using Iface = sdbusplus::server::object::object<
33 sdbusplus::org::open_power::OCC::server::PassThrough>;
34
35/** @class PassThrough
36 * @brief Implements org.open_power.OCC.PassThrough
37 */
38class PassThrough : public Iface
39{
40 public:
41 PassThrough() = delete;
42 PassThrough(const PassThrough&) = delete;
43 PassThrough& operator=(const PassThrough&) = delete;
44 PassThrough(PassThrough&&) = default;
45 PassThrough& operator=(PassThrough&&) = default;
46 ~PassThrough() = default;
47
48 /** @brief Ctor to put pass-through d-bus object on the bus
49 * @param[in] bus - Bus to attach to
50 * @param[in] path - Path to attach at
51 */
52 PassThrough(sdbusplus::bus::bus& bus,
53 const char* path);
54
55 /** @brief Pass through command to OCC
56 * @param[in] command - command to pass-through
57 * @returns OCC response as an array
58 */
59 std::vector<std::int32_t>
60 send(std::vector<std::int32_t> command) override;
61
62 private:
63 /** @brief Pass-through occ path on the bus */
64 std::string path;
65};
66
67} // namespace pass_through
68} // namespace occ
69} // namespace open_power