3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Class named_scope</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 1. Boost.Log v2">
8 <link rel="up" href="../../../attributes.html#header.boost.log.attributes.named_scope_hpp" title="Header <boost/log/attributes/named_scope.hpp>">
9 <link rel="prev" href="mutable__idm45711348642864/impl.html" title="Class impl">
10 <link rel="next" href="named_scope/sentry.html" title="Struct sentry">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
15 <div class="spirit-nav">
16 <a accesskey="p" href="mutable__idm45711348642864/impl.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.named_scope_hpp"><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="named_scope/sentry.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
18 <div class="refentry">
19 <a name="boost.log.attributes.named_scope"></a><div class="titlepage"></div>
20 <div class="refnamediv">
21 <h2><span class="refentrytitle">Class named_scope</span></h2>
22 <p>boost::log::attributes::named_scope — A class of an attribute that holds stack of named scopes of the current thread. </p>
24 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
25 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../../attributes.html#header.boost.log.attributes.named_scope_hpp" title="Header <boost/log/attributes/named_scope.hpp>">boost/log/attributes/named_scope.hpp</a>>
28 <span class="keyword">class</span> <a class="link" href="named_scope.html" title="Class named_scope">named_scope</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">attribute</span> <span class="special">{</span>
29 <span class="keyword">public</span><span class="special">:</span>
30 <span class="comment">// types</span>
31 <span class="keyword">typedef</span> <a class="link" href="named_scope_list.html" title="Class named_scope_list">named_scope_list</a> <a name="boost.log.attributes.named_scope.value_type"></a><span class="identifier">value_type</span><span class="special">;</span> <span class="comment">// Scope names stack (the attribute value type) </span>
32 <span class="keyword">typedef</span> <span class="identifier">value_type</span><span class="special">::</span><span class="identifier">value_type</span> <a name="boost.log.attributes.named_scope.scope_entry"></a><span class="identifier">scope_entry</span><span class="special">;</span> <span class="comment">// Scope entry. </span>
34 <span class="comment">// member classes/structs/unions</span>
36 <span class="comment">// Sentry object class to automatically push and pop scopes.</span>
38 <span class="keyword">struct</span> <a class="link" href="named_scope/sentry.html" title="Struct sentry">sentry</a> <span class="special">{</span>
39 <span class="comment">// <a class="link" href="named_scope/sentry.html#boost.log.attributes.named_scope.sentryconstruct-copy-destruct">construct/copy/destruct</a></span>
40 <a class="link" href="named_scope/sentry.html#idm45711348601696-bb"><span class="identifier">sentry</span></a><span class="special">(</span><span class="identifier">string_literal</span> <span class="keyword">const</span> <span class="special">&</span><span class="special">,</span> <span class="identifier">string_literal</span> <span class="keyword">const</span> <span class="special">&</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">,</span>
41 <span class="identifier">scope_entry</span><span class="special">::</span><span class="identifier">scope_name_type</span> <span class="special">=</span> <span class="identifier">scope_entry</span><span class="special">::</span><span class="identifier">general</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
42 <a class="link" href="named_scope/sentry.html#idm45711348595248-bb"><span class="identifier">sentry</span></a><span class="special">(</span><a class="link" href="named_scope/sentry.html" title="Struct sentry">sentry</a> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
43 <a class="link" href="named_scope/sentry.html" title="Struct sentry">sentry</a> <span class="special">&</span> <a class="link" href="named_scope/sentry.html#idm45711348593712-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="named_scope/sentry.html" title="Struct sentry">sentry</a> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
44 <a class="link" href="named_scope/sentry.html#idm45711348596016-bb"><span class="special">~</span><span class="identifier">sentry</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
45 <span class="special">}</span><span class="special">;</span>
47 <span class="comment">// <a class="link" href="named_scope.html#boost.log.attributes.named_scopeconstruct-copy-destruct">construct/copy/destruct</a></span>
48 <a class="link" href="named_scope.html#idm45711348588448-bb"><span class="identifier">named_scope</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
49 <span class="keyword">explicit</span> <a class="link" href="named_scope.html#idm45711348587728-bb"><span class="identifier">named_scope</span></a><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span>
51 <span class="comment">// <a class="link" href="named_scope.html#idm45711348585760-bb">public static functions</a></span>
52 <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="named_scope.html#idm45711348585200-bb"><span class="identifier">push_scope</span></a><span class="special">(</span><span class="identifier">scope_entry</span> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
53 <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="named_scope.html#idm45711348581792-bb"><span class="identifier">pop_scope</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
54 <span class="keyword">static</span> <span class="identifier">value_type</span> <span class="keyword">const</span> <span class="special">&</span> <a class="link" href="named_scope.html#idm45711348579072-bb"><span class="identifier">get_scopes</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
55 <span class="special">}</span><span class="special">;</span></pre></div>
56 <div class="refsect1">
57 <a name="idm45554751027088"></a><h2>Description</h2>
58 <p>The basic_named_scope attribute is essentially a hook to the thread-specific instance of scope list. This means that the attribute will generate different values if get_value is called in different threads. The attribute generates value with stored type <code class="computeroutput">basic_named_scope_list< CharT ></code>.</p>
59 <p>The attribute class can also be used to gain access to the scope stack instance, e.g. to get its copy or to push or pop a scope entry. However, it is highly not recommended to maintain scope list manually. Use <code class="computeroutput">BOOST_LOG_NAMED_SCOPE</code> or <code class="computeroutput">BOOST_LOG_FUNCTION</code> macros instead. </p>
60 <div class="refsect2">
61 <a name="idm45554751023504"></a><h3>
62 <a name="boost.log.attributes.named_scopeconstruct-copy-destruct"></a><code class="computeroutput">named_scope</code>
64 construct/copy/destruct</h3>
65 <div class="orderedlist"><ol class="orderedlist" type="1">
67 <pre class="literallayout"><a name="idm45711348588448-bb"></a><span class="identifier">named_scope</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
68 <p>Constructor. Creates an attribute. </p>
71 <pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45711348587728-bb"></a><span class="identifier">named_scope</span><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&</span> source<span class="special">)</span><span class="special">;</span></pre>
72 <p>Constructor for casting support </p>
76 <div class="refsect2">
77 <a name="idm45554751010400"></a><h3>
78 <a name="idm45711348585760-bb"></a><code class="computeroutput">named_scope</code> public static functions</h3>
79 <div class="orderedlist"><ol class="orderedlist" type="1">
81 <pre class="literallayout"><span class="keyword">static</span> <span class="keyword">void</span> <a name="idm45711348585200-bb"></a><span class="identifier">push_scope</span><span class="special">(</span><span class="identifier">scope_entry</span> <span class="keyword">const</span> <span class="special">&</span> entry<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
82 <p>The method pushes the scope to the back of the current thread's scope list</p>
83 <p><span class="bold"><strong>Throws:</strong></span> Nothing. </p>
86 <pre class="literallayout"><span class="keyword">static</span> <span class="keyword">void</span> <a name="idm45711348581792-bb"></a><span class="identifier">pop_scope</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
87 <p>The method pops the last pushed scope from the current thread's scope list</p>
88 <p><span class="bold"><strong>Throws:</strong></span> Nothing. </p>
91 <pre class="literallayout"><span class="keyword">static</span> <span class="identifier">value_type</span> <span class="keyword">const</span> <span class="special">&</span> <a name="idm45711348579072-bb"></a><span class="identifier">get_scopes</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
94 <div class="note"><table border="0" summary="Note">
96 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
97 <th align="left">Note</th>
99 <tr><td align="left" valign="top"><p>The returned reference is only valid until the current thread ends. The scopes in the returned container may change if the execution scope is changed (i.e. either <code class="computeroutput">push_scope</code> or <code class="computeroutput">pop_scope</code> is called). User has to copy the stack if he wants to keep it intact regardless of the execution scope. </p></td></tr>
103 <div class="variablelist"><table border="0" class="variablelist compact">
105 <col align="left" valign="top">
109 <td><p><span class="term">Returns:</span></p></td>
110 <td><p>The current thread's list of scopes</p></td>
118 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
119 <td align="left"></td>
120 <td align="right"><div class="copyright-footer">Copyright © 2007-2016 Andrey Semashev<p>
121 Distributed under the Boost Software License, Version 1.0. (See accompanying
122 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>).
127 <div class="spirit-nav">
128 <a accesskey="p" href="mutable__idm45711348642864/impl.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.named_scope_hpp"><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="named_scope/sentry.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>