~ai.tron/armagetronad/0.4-winlibs-updated

« back to all changes in this revision

Viewing changes to boost/includes/boost/log/attributes/attribute.hpp

  • Committer: Nik K.
  • Date: 2013-11-07 16:58:35 UTC
  • Revision ID: nik.karbaum@gmail.com-20131107165835-kq99jz23drfj4dkh
Forgot to add some files; here they are

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *          Copyright Andrey Semashev 2007 - 2013.
 
3
 * Distributed under the Boost Software License, Version 1.0.
 
4
 *    (See accompanying file LICENSE_1_0.txt or copy at
 
5
 *          http://www.boost.org/LICENSE_1_0.txt)
 
6
 */
 
7
/*!
 
8
 * \file   attribute.hpp
 
9
 * \author Andrey Semashev
 
10
 * \date   15.04.2007
 
11
 *
 
12
 * The header contains attribute interface definition.
 
13
 */
 
14
 
 
15
#ifndef BOOST_LOG_ATTRIBUTES_ATTRIBUTE_HPP_INCLUDED_
 
16
#define BOOST_LOG_ATTRIBUTES_ATTRIBUTE_HPP_INCLUDED_
 
17
 
 
18
#include <new>
 
19
#include <boost/intrusive_ptr.hpp>
 
20
#include <boost/move/core.hpp>
 
21
#include <boost/log/detail/config.hpp>
 
22
#include <boost/log/utility/intrusive_ref_counter.hpp>
 
23
#include <boost/log/utility/explicit_operator_bool.hpp>
 
24
#include <boost/log/detail/header.hpp>
 
25
 
 
26
#ifdef BOOST_LOG_HAS_PRAGMA_ONCE
 
27
#pragma once
 
28
#endif
 
29
 
 
30
namespace boost {
 
31
 
 
32
BOOST_LOG_OPEN_NAMESPACE
 
33
 
 
34
#ifndef BOOST_LOG_DOXYGEN_PASS
 
35
 
 
36
class attribute_value;
 
37
 
 
38
namespace aux {
 
39
 
 
40
//! Reference proxy object to implement \c operator[]
 
41
class attribute_set_reference_proxy;
 
42
 
 
43
} // namespace aux
 
44
 
 
45
#endif // BOOST_LOG_DOXYGEN_PASS
 
46
 
 
47
/*!
 
48
 * \brief A base class for an attribute value factory
 
49
 *
 
50
 * Every attribute is represented with a factory that is basically an attribute value generator.
 
51
 * The sole purpose of an attribute is to return an actual value when requested. A simplest attribute
 
52
 * can always return the same value that it stores internally, but more complex ones can
 
53
 * perform a considerable amount of work to return a value, and the returned values may differ
 
54
 * each time requested.
 
55
 *
 
56
 * A word about thread safety. An attribute should be prepared to be requested a value from
 
57
 * multiple threads concurrently.
 
58
 */
 
59
class attribute
 
60
{
 
61
    BOOST_COPYABLE_AND_MOVABLE(attribute)
 
62
 
 
63
public:
 
64
    /*!
 
65
     * \brief A base class for an attribute value factory
 
66
     *
 
67
     * All attributes must derive their implementation from this class.
 
68
     */
 
69
    struct BOOST_LOG_NO_VTABLE BOOST_LOG_VISIBLE impl :
 
70
        public intrusive_ref_counter
 
71
    {
 
72
        /*!
 
73
         * \return The actual attribute value. It shall not return empty values (exceptions
 
74
         *         shall be used to indicate errors).
 
75
         */
 
76
        virtual attribute_value get_value() = 0;
 
77
 
 
78
        BOOST_LOG_API static void* operator new (std::size_t size);
 
79
        BOOST_LOG_API static void operator delete (void* p, std::size_t size) BOOST_NOEXCEPT;
 
80
    };
 
81
 
 
82
private:
 
83
    //! Pointer to the attribute factory implementation
 
84
    intrusive_ptr< impl > m_pImpl;
 
85
 
 
86
public:
 
87
    /*!
 
88
     * Default constructor. Creates an empty attribute value factory, which is not usable until
 
89
     * \c set_impl is called.
 
90
     */
 
91
    BOOST_LOG_DEFAULTED_FUNCTION(attribute(), {})
 
92
 
 
93
    /*!
 
94
     * Copy constructor
 
95
     */
 
96
    attribute(attribute const& that) BOOST_NOEXCEPT : m_pImpl(that.m_pImpl) {}
 
97
 
 
98
    /*!
 
99
     * Move constructor
 
100
     */
 
101
    attribute(BOOST_RV_REF(attribute) that) BOOST_NOEXCEPT { m_pImpl.swap(that.m_pImpl); }
 
102
 
 
103
    /*!
 
104
     * Initializing constructor
 
105
     *
 
106
     * \param p Pointer to the implementation. Must not be \c NULL.
 
107
     */
 
108
    explicit attribute(intrusive_ptr< impl > p) BOOST_NOEXCEPT { m_pImpl.swap(p); }
 
109
 
 
110
    /*!
 
111
     * Copy assignment
 
112
     */
 
113
    attribute& operator= (BOOST_COPY_ASSIGN_REF(attribute) that) BOOST_NOEXCEPT
 
114
    {
 
115
        m_pImpl = that.m_pImpl;
 
116
        return *this;
 
117
    }
 
118
 
 
119
    /*!
 
120
     * Move assignment
 
121
     */
 
122
    attribute& operator= (BOOST_RV_REF(attribute) that) BOOST_NOEXCEPT
 
123
    {
 
124
        m_pImpl.swap(that.m_pImpl);
 
125
        return *this;
 
126
    }
 
127
 
 
128
#ifndef BOOST_LOG_DOXYGEN_PASS
 
129
    attribute& operator= (aux::attribute_set_reference_proxy const& that) BOOST_NOEXCEPT;
 
130
#endif
 
131
 
 
132
    /*!
 
133
     * Verifies that the factory is not in empty state
 
134
     */
 
135
    BOOST_LOG_EXPLICIT_OPERATOR_BOOL()
 
136
 
 
137
    /*!
 
138
     * Verifies that the factory is in empty state
 
139
     */
 
140
    bool operator! () const BOOST_NOEXCEPT { return !m_pImpl; }
 
141
 
 
142
    /*!
 
143
     * \return The actual attribute value. It shall not return empty values (exceptions
 
144
     *         shall be used to indicate errors).
 
145
     */
 
146
    attribute_value get_value() const;
 
147
 
 
148
    /*!
 
149
     * The method swaps two factories (i.e. their implementations).
 
150
     */
 
151
    void swap(attribute& that) BOOST_NOEXCEPT { m_pImpl.swap(that.m_pImpl); }
 
152
 
 
153
protected:
 
154
    /*!
 
155
     * \returns The pointer to the implementation
 
156
     */
 
157
    impl* get_impl() const BOOST_NOEXCEPT { return m_pImpl.get(); }
 
158
    /*!
 
159
     * Sets the pointer to the factory implementation.
 
160
     *
 
161
     * \param p Pointer to the implementation. Must not be \c NULL.
 
162
     */
 
163
    void set_impl(intrusive_ptr< impl > p) BOOST_NOEXCEPT { m_pImpl.swap(p); }
 
164
 
 
165
    template< typename T >
 
166
    friend T attribute_cast(attribute const&);
 
167
};
 
168
 
 
169
/*!
 
170
 * The function swaps two attribute value factories
 
171
 */
 
172
inline void swap(attribute& left, attribute& right) BOOST_NOEXCEPT
 
173
{
 
174
    left.swap(right);
 
175
}
 
176
 
 
177
BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
178
 
 
179
} // namespace boost
 
180
 
 
181
#include <boost/log/detail/footer.hpp>
 
182
#if defined(BOOST_LOG_ATTRIBUTES_ATTRIBUTE_VALUE_HPP_INCLUDED_)
 
183
#include <boost/log/detail/attribute_get_value_impl.hpp>
 
184
#endif
 
185
 
 
186
#endif // BOOST_LOG_ATTRIBUTES_ATTRIBUTE_HPP_INCLUDED_