rippled
WorkPlain.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2016 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_APP_MISC_DETAIL_WORKPLAIN_H_INCLUDED
21 #define RIPPLE_APP_MISC_DETAIL_WORKPLAIN_H_INCLUDED
22 
23 #include <ripple/app/misc/detail/WorkBase.h>
24 
25 namespace ripple {
26 
27 namespace detail {
28 
29 // Work over TCP/IP
30 class WorkPlain : public WorkBase<WorkPlain>,
31  public std::enable_shared_from_this<WorkPlain>
32 {
33  friend class WorkBase<WorkPlain>;
34 
35 public:
36  WorkPlain(
37  std::string const& host,
38  std::string const& path,
39  std::string const& port,
40  boost::asio::io_service& ios,
41  endpoint_type const& lastEndpoint,
42  bool lastStatus,
43  callback_type cb);
44  ~WorkPlain() = default;
45 
46 private:
47  void
48  onConnect(error_code const& ec);
49 
52  {
53  return socket_;
54  }
55 };
56 
57 //------------------------------------------------------------------------------
58 
60  std::string const& host,
61  std::string const& path,
62  std::string const& port,
63  boost::asio::io_service& ios,
64  endpoint_type const& lastEndpoint,
65  bool lastStatus,
66  callback_type cb)
67  : WorkBase(host, path, port, ios, lastEndpoint, lastStatus, cb)
68 {
69 }
70 
71 void
73 {
74  if (ec)
75  return fail(ec);
76 
77  onStart();
78 }
79 
80 } // namespace detail
81 
82 } // namespace ripple
83 
84 #endif
ripple::detail::WorkBase< WorkPlain >::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: WorkBase.h:44
ripple::detail::WorkPlain
Definition: WorkPlain.h:30
std::string
STL class.
ripple::detail::WorkBase< WorkPlain >::fail
void fail(error_code const &ec)
Definition: WorkBase.h:183
ripple::detail::WorkBase< WorkPlain >::socket_
socket_type socket_
Definition: WorkBase.h:64
std::function< void(error_code const &, endpoint_type const &, response_type &&)>
ripple::detail::WorkPlain::WorkPlain
WorkPlain(std::string const &host, std::string const &path, std::string const &port, boost::asio::io_service &ios, endpoint_type const &lastEndpoint, bool lastStatus, callback_type cb)
Definition: WorkPlain.h:59
ripple::detail::WorkBase< WorkPlain >::onStart
void onStart()
Definition: WorkBase.h:243
ripple::detail::WorkPlain::~WorkPlain
~WorkPlain()=default
std::enable_shared_from_this
ripple::detail::WorkBase
Definition: WorkBase.h:40
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::detail::WorkPlain::onConnect
void onConnect(error_code const &ec)
Definition: WorkPlain.h:72
ripple::detail::WorkBase< WorkPlain >::error_code
boost::system::error_code error_code
Definition: WorkBase.h:43
ripple::detail::WorkBase< WorkPlain >::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: WorkBase.h:51
ripple::detail::WorkPlain::stream
socket_type & stream()
Definition: WorkPlain.h:51