blob: fa020ef06de94cef65b2f19619cad12dd7a4bfc5 [file] [log] [blame]
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07003 * Copyright (c) 2014, Regents of the University of California.
4 *
5 * This file is part of NDN repo-ng (Next generation of NDN repository).
6 * See AUTHORS.md for complete list of repo-ng authors and contributors.
7 *
8 * repo-ng is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070018 */
19
20#ifndef REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP
21#define REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP
22
23#include "ndn-handle-common.hpp"
24#include <boost/asio.hpp>
25
26namespace repo {
27
28class TcpBulkInsertHandle : noncopyable
29{
30public:
31 class Error : public std::runtime_error
32 {
33 public:
34 explicit
35 Error(const std::string& what)
36 : std::runtime_error(what)
37 {
38 }
39 };
40
41public:
42 TcpBulkInsertHandle(boost::asio::io_service& ioService,
43 StorageHandle& storageHandle);
44
45 void
46 listen(const std::string& host, const std::string& port);
47
48 void
49 stop();
50
51 StorageHandle&
52 getStorageHandle()
53 {
54 return m_storageHandle;
55 }
56
57private:
58 void
59 handleAccept(const boost::system::error_code& error,
60 const shared_ptr<boost::asio::ip::tcp::socket>& socket);
61
62private:
63 boost::asio::ip::tcp::acceptor m_acceptor;
64 boost::asio::ip::tcp::endpoint m_localEndpoint;
65 StorageHandle& m_storageHandle;
66};
67
68} // namespace repo
69
70#endif // REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP