Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Regents of the University of California. |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP |
| 8 | #define REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP |
| 9 | |
| 10 | #include "ndn-handle-common.hpp" |
| 11 | #include <boost/asio.hpp> |
| 12 | |
| 13 | namespace repo { |
| 14 | |
| 15 | class TcpBulkInsertHandle : noncopyable |
| 16 | { |
| 17 | public: |
| 18 | class Error : public std::runtime_error |
| 19 | { |
| 20 | public: |
| 21 | explicit |
| 22 | Error(const std::string& what) |
| 23 | : std::runtime_error(what) |
| 24 | { |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | public: |
| 29 | TcpBulkInsertHandle(boost::asio::io_service& ioService, |
| 30 | StorageHandle& storageHandle); |
| 31 | |
| 32 | void |
| 33 | listen(const std::string& host, const std::string& port); |
| 34 | |
| 35 | void |
| 36 | stop(); |
| 37 | |
| 38 | StorageHandle& |
| 39 | getStorageHandle() |
| 40 | { |
| 41 | return m_storageHandle; |
| 42 | } |
| 43 | |
| 44 | private: |
| 45 | void |
| 46 | handleAccept(const boost::system::error_code& error, |
| 47 | const shared_ptr<boost::asio::ip::tcp::socket>& socket); |
| 48 | |
| 49 | private: |
| 50 | boost::asio::ip::tcp::acceptor m_acceptor; |
| 51 | boost::asio::ip::tcp::endpoint m_localEndpoint; |
| 52 | StorageHandle& m_storageHandle; |
| 53 | }; |
| 54 | |
| 55 | } // namespace repo |
| 56 | |
| 57 | #endif // REPO_NDN_HANDLE_WRITE_TCP_BACKDOOR_HPP |