rippled
Loading...
Searching...
No Matches
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 <xrpld/app/misc/detail/WorkBase.h>
24
25namespace ripple {
26
27namespace detail {
28
29// Work over TCP/IP
30class WorkPlain : public WorkBase<WorkPlain>,
31 public std::enable_shared_from_this<WorkPlain>
32{
33 friend class WorkBase<WorkPlain>;
34
35public:
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
46private:
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
71void
72WorkPlain::onConnect(error_code const& ec)
73{
74 if (ec)
75 return fail(ec);
76
77 onStart();
78}
79
80} // namespace detail
81
82} // namespace ripple
83
84#endif
boost::asio::ip::tcp::socket socket_type
Definition: WorkBase.h:50
boost::asio::ip::tcp::endpoint endpoint_type
Definition: WorkBase.h:43
boost::system::error_code error_code
Definition: WorkBase.h:42
std::function< void(error_code const &, endpoint_type const &, response_type &&)> callback_type
Definition: WorkBase.h:47
void fail(error_code const &ec)
Definition: WorkBase.h:185
socket_type & stream()
Definition: WorkPlain.h:51
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
void onConnect(error_code const &ec)
Definition: WorkPlain.h:72
Add a path.
Definition: paths.h:58
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26