1 // +------------------------------------------------------------------+
2 // | ____ _ _ __ __ _ __ |
3 // | / ___| |__ ___ ___| | __ | \/ | |/ / |
4 // | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
5 // | | |___| | | | __/ (__| < | | | | . \ |
6 // | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
8 // | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
9 // +------------------------------------------------------------------+
11 // This file is part of Check_MK.
12 // The official homepage is at http://mathias-kettner.de/check_mk.
14 // check_mk is free software; you can redistribute it and/or modify it
15 // under the terms of the GNU General Public License as published by
16 // the Free Software Foundation in version 2. check_mk is distributed
17 // in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
18 // out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19 // PARTICULAR PURPOSE. See the GNU General Public License for more de-
20 // tails. You should have received a copy of the GNU General Public
21 // License along with GNU Make; see the file COPYING. If not, write
22 // to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 // Boston, MA 02110-1301 USA.
25 #include "CommentColumn.h"
30 #include "MonitoringCore.h"
35 void CommentColumn::output(Row row
, RowRenderer
&r
,
36 const contact
* /*auth_user*/,
37 std::chrono::seconds
/*timezone_offset*/) const {
39 for (const auto &comment
: comments_for_row(row
)) {
42 s
.output(comment
._id
);
43 s
.output(comment
._author
);
44 s
.output(comment
._comment
);
45 if (_with_extra_info
) {
46 s
.output(comment
._entry_type
);
47 s
.output(comment
._entry_time
);
50 l
.output(comment
._id
);
55 std::vector
<std::string
> CommentColumn::getValue(
56 Row row
, const contact
* /*auth_user*/,
57 std::chrono::seconds
/*timezone_offset*/) const {
58 std::vector
<std::string
> ids
;
59 auto comments
= comments_for_row(row
);
61 comments
.begin(), comments
.end(), std::back_inserter(ids
),
62 [](const auto &comment
) { return std::to_string(comment
._id
); });
66 std::vector
<CommentData
> CommentColumn::comments_for_row(Row row
) const {
67 if (auto data
= columnData
<void>(row
)) {
69 ? _mc
->comments_for_service(
70 reinterpret_cast<const MonitoringCore::Service
*>(
72 : _mc
->comments_for_host(
73 reinterpret_cast<const MonitoringCore::Host
*>(data
));