]> git.sesse.net Git - casparcg/blob - protocol/log/tcp_logger_protocol_strategy.cpp
Fix a few Clang warnings.
[casparcg] / protocol / log / tcp_logger_protocol_strategy.cpp
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Helge Norberg, helge.norberg@svt.se
20 */
21
22 #include "../StdAfx.h"
23
24 #include "tcp_logger_protocol_strategy.h"
25
26 #include <common/log.h>
27
28 namespace caspar { namespace protocol { namespace log {
29
30 class tcp_logger_protocol_strategy : public IO::protocol_strategy<char>
31 {
32         spl::shared_ptr<IO::client_connection<char>>    client_connection_;
33         std::shared_ptr<void>                                                   log_sink_                       = caspar::log::add_preformatted_line_sink([=](std::string line)
34                                                                                                                                                                 {
35                                                                                                                                                                         handle_log_line(std::move(line));
36                                                                                                                                                                 });
37 public:
38         tcp_logger_protocol_strategy(spl::shared_ptr<IO::client_connection<char>> client_connection)
39                 : client_connection_(std::move(client_connection))
40         {
41         }
42
43         void handle_log_line(std::string line)
44         {
45                 line += "\r\n";
46                 client_connection_->send(std::move(line));
47         }
48
49         void parse(const std::string& data) override
50         {
51         }
52 };
53
54 spl::shared_ptr<IO::protocol_strategy<char>> tcp_logger_protocol_strategy_factory::create(
55                 const spl::shared_ptr<IO::client_connection<char>>& client_connection)
56 {
57         return spl::make_shared<tcp_logger_protocol_strategy>(client_connection);
58 }
59
60 }}}