blob: e058edf4fb0bdebbceb4b3a5435d0d24a78a1161 [file] [log] [blame]
Artem Senichevefd5d742018-10-24 16:14:04 +03001/**
2 * @brief Server side implementation of the D-Bus interface
3 *
4 * This file is part of HostLogger project.
5 *
6 * Copyright (c) 2018 YADRO
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#pragma once
22
23#include "log_manager.hpp"
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080024
Artem Senichevefd5d742018-10-24 16:14:04 +030025#include <xyz/openbmc_project/HostLogger/server.hpp>
26
27/** @brief D-Bus interface name. */
28#define HOSTLOGGER_DBUS_IFACE "xyz.openbmc_project.HostLogger"
29/** @brief D-Bus path. */
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080030#define HOSTLOGGER_DBUS_PATH "/xyz/openbmc_project/HostLogger"
Artem Senichevefd5d742018-10-24 16:14:04 +030031
32/** @brief unique_ptr functor to release an event reference. */
33struct EventDeleter
34{
35 void operator()(sd_event* event) const
36 {
37 sd_event_unref(event);
38 }
39};
40
41/* @brief Alias 'event' to a unique_ptr type for auto-release. */
42using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
43
44// Typedef for super class
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080045using server_inherit = sdbusplus::server::object_t<
46 sdbusplus::xyz::openbmc_project::server::HostLogger>;
Artem Senichevefd5d742018-10-24 16:14:04 +030047
48/** @class DbusServer
49 * @brief D-Bus service by host logger.
50 */
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080051class DbusServer : public server_inherit
Artem Senichevefd5d742018-10-24 16:14:04 +030052{
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080053 public:
Artem Senichevefd5d742018-10-24 16:14:04 +030054 /** @brief Constructor.
55 *
56 * @param[in] logManager - log manager
57 * @param[in] bus - bus to attach to
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080058 * @param[in] path - bath to attach at, optional, default is
59 * HOSTLOGGER_DBUS_PATH
Artem Senichevefd5d742018-10-24 16:14:04 +030060 */
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080061 DbusServer(LogManager& logManager, sdbusplus::bus::bus& bus,
62 const char* path = HOSTLOGGER_DBUS_PATH);
Artem Senichevefd5d742018-10-24 16:14:04 +030063
64 // From server_inherit
65 void flush();
66
Patrick Venture4d5a5dc2018-11-14 08:51:13 -080067 private:
Artem Senichevefd5d742018-10-24 16:14:04 +030068 /** @brief Log manager instance. */
69 LogManager& logManager_;
70};