Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / beast / doc / html / beast / ref / boost__beast__get_lowest_layer.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>get_lowest_layer</title>
5 <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Beast">
8 <link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
9 <link rel="prev" href="boost__beast__generic_category.html" title="generic_category">
10 <link rel="next" href="boost__beast__has_get_executor.html" title="has_get_executor">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="boost__beast__generic_category.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__has_get_executor.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="beast.ref.boost__beast__get_lowest_layer"></a><a class="link" href="boost__beast__get_lowest_layer.html" title="get_lowest_layer">get_lowest_layer</a>
28 </h4></div></div></div>
29 <p>
30         <a class="indexterm" name="idm45873507426096"></a>
31 Return the lowest layer in a stack of stream layers.
32       </p>
33 <h5>
34 <a name="beast.ref.boost__beast__get_lowest_layer.h0"></a>
35         <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.synopsis"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.synopsis">Synopsis</a>
36       </h5>
37 <p>
38         Defined in header <code class="literal">&lt;<a href="../../../../../../boost/beast/core/stream_traits.hpp" target="_top">boost/beast/core/stream_traits.hpp</a>&gt;</code>
39       </p>
40 <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
41     <span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
42 <span class="identifier">lowest_layer_type</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;&amp;</span>
43 <span class="identifier">get_lowest_layer</span><span class="special">(</span>
44     <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">t</span><span class="special">);</span>
45 </pre>
46 <h5>
47 <a name="beast.ref.boost__beast__get_lowest_layer.h1"></a>
48         <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.description"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.description">Description</a>
49       </h5>
50 <p>
51         If <code class="computeroutput"><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">()</span></code>
52         is well-defined, returns <code class="computeroutput"><span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">())</span></code>.
53         Otherwise, it returns <code class="computeroutput"><span class="identifier">t</span></code>.
54         A stream layer is an object of class type which wraps another object through
55         composition, and meets some or all of the named requirements of the wrapped
56         type while optionally changing behavior. Examples of stream layers include
57         <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream</span></code>
58         or <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a>. The owner of a stream layer
59         can interact directly with the wrapper, by passing it to stream algorithms.
60         Or, the owner can obtain a reference to the wrapped object by calling <code class="computeroutput"><span class="identifier">next_layer</span><span class="special">()</span></code>
61         and accessing its members. This is necessary when it is desired to access
62         functionality in the next layer which is not available in the wrapper. For
63         example, <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a> permits reading and writing,
64         but in order to establish the underlying connection, members of the wrapped
65         stream (such as <code class="computeroutput"><span class="identifier">connect</span></code>)
66         must be invoked directly. Usually the last object in the chain of composition
67         is the concrete socket object (for example, a <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">basic_socket</span></code>
68         or a class derived from it). The function <a class="link" href="boost__beast__get_lowest_layer.html" title="get_lowest_layer"><code class="computeroutput"><span class="identifier">get_lowest_layer</span></code></a> exists to easily
69         obtain the concrete socket when it is desired to perform an action that is
70         not prescribed by a named requirement, such as changing a socket option,
71         cancelling all pending asynchronous I/O, or closing the socket (perhaps by
72         using <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>).
73       </p>
74 <h5>
75 <a name="beast.ref.boost__beast__get_lowest_layer.h2"></a>
76         <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.example"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.example">Example</a>
77       </h5>
78 <pre class="programlisting"><span class="comment">// Set non-blocking mode on a stack of stream</span>
79 <span class="comment">// layers with a regular socket at the lowest layer.</span>
80 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Stream</span><span class="special">&gt;</span>
81 <span class="keyword">void</span> <span class="identifier">set_non_blocking</span> <span class="special">(</span><span class="identifier">Stream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">)</span>
82 <span class="special">{</span>
83     <span class="identifier">error_code</span> <span class="identifier">ec</span><span class="special">;</span>
84     <span class="comment">// A compile error here means your lowest layer is not the right type!</span>
85     <span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">stream</span><span class="special">).</span><span class="identifier">non_blocking</span><span class="special">(</span><span class="keyword">true</span><span class="special">,</span> <span class="identifier">ec</span><span class="special">);</span>
86     <span class="keyword">if</span><span class="special">(</span><span class="identifier">ec</span><span class="special">)</span>
87         <span class="keyword">throw</span> <span class="identifier">system_error</span><span class="special">{</span><span class="identifier">ec</span><span class="special">};</span>
88 <span class="special">}</span>
89 </pre>
90 <h5>
91 <a name="beast.ref.boost__beast__get_lowest_layer.h3"></a>
92         <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.parameters"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.parameters">Parameters</a>
93       </h5>
94 <div class="informaltable"><table class="table">
95 <colgroup>
96 <col>
97 <col>
98 </colgroup>
99 <thead><tr>
100 <th>
101                 <p>
102                   Name
103                 </p>
104               </th>
105 <th>
106                 <p>
107                   Description
108                 </p>
109               </th>
110 </tr></thead>
111 <tbody><tr>
112 <td>
113                 <p>
114                   <code class="computeroutput"><span class="identifier">t</span></code>
115                 </p>
116               </td>
117 <td>
118                 <p>
119                   The layer in a stack of layered objects for which the lowest layer
120                   is returned.
121                 </p>
122               </td>
123 </tr></tbody>
124 </table></div>
125 <h5>
126 <a name="beast.ref.boost__beast__get_lowest_layer.h4"></a>
127         <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.see_also"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.see_also">See
128         Also</a>
129       </h5>
130 <p>
131         <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>,
132         <a class="link" href="boost__beast__lowest_layer_type.html" title="lowest_layer_type"><code class="computeroutput"><span class="identifier">lowest_layer_type</span></code></a>
133       </p>
134 <p>
135         Convenience header <code class="literal">&lt;<a href="../../../../../../boost/beast/core.hpp" target="_top">boost/beast/core.hpp</a>&gt;</code>
136       </p>
137 </div>
138 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
139 <td align="left"></td>
140 <td align="right"><div class="copyright-footer">Copyright &#169; 2016-2019 Vinnie
141       Falco<p>
142         Distributed under the Boost Software License, Version 1.0. (See accompanying
143         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
144       </p>
145 </div></td>
146 </tr></table>
147 <hr>
148 <div class="spirit-nav">
149 <a accesskey="p" href="boost__beast__generic_category.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__has_get_executor.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
150 </div>
151 </body>
152 </html>