blob: 1e6d47cd6eff3dafc9c238a64052d893306bb1d8 [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"
24#include <xyz/openbmc_project/HostLogger/server.hpp>
25
26/** @brief D-Bus interface name. */
27#define HOSTLOGGER_DBUS_IFACE "xyz.openbmc_project.HostLogger"
28/** @brief D-Bus path. */
29#define HOSTLOGGER_DBUS_PATH "/xyz/openbmc_project/HostLogger"
30
31/** @brief unique_ptr functor to release an event reference. */
32struct EventDeleter
33{
34 void operator()(sd_event* event) const
35 {
36 sd_event_unref(event);
37 }
38};
39
40/* @brief Alias 'event' to a unique_ptr type for auto-release. */
41using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
42
43// Typedef for super class
44using server_inherit = sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::server::HostLogger>;
45
46
47/** @class DbusServer
48 * @brief D-Bus service by host logger.
49 */
50class DbusServer: public server_inherit
51{
52public:
53 /** @brief Constructor.
54 *
55 * @param[in] logManager - log manager
56 * @param[in] bus - bus to attach to
57 * @param[in] path - bath to attach at, optional, default is HOSTLOGGER_DBUS_PATH
58 */
59 DbusServer(LogManager& logManager, sdbusplus::bus::bus& bus, const char* path = HOSTLOGGER_DBUS_PATH);
60
61 // From server_inherit
62 void flush();
63
64private:
65 /** @brief Log manager instance. */
66 LogManager& logManager_;
67};