BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma_managedallocator.h
Go to the documentation of this file.
1/// @file bslma_managedallocator.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslma_managedallocator.h -*-C++-*-
8#ifndef INCLUDED_BSLMA_MANAGEDALLOCATOR
9#define INCLUDED_BSLMA_MANAGEDALLOCATOR
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslma_managedallocator bslma_managedallocator
15/// @brief Provide a protocol for memory allocators that support `release`.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslma
19/// @{
20/// @addtogroup bslma_managedallocator
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslma_managedallocator-purpose"> Purpose</a>
25/// * <a href="#bslma_managedallocator-classes"> Classes </a>
26/// * <a href="#bslma_managedallocator-description"> Description </a>
27/// * <a href="#bslma_managedallocator-usage"> Usage </a>
28///
29/// # Purpose {#bslma_managedallocator-purpose}
30/// Provide a protocol for memory allocators that support `release`.
31///
32/// @deprecated use @ref bdlma_managedallocator instead.
33///
34/// # Classes {#bslma_managedallocator-classes}
35///
36/// - bslma::ManagedAllocator: protocol for allocators with `release` capability
37///
38/// @see bslma_allocator
39///
40/// # Description {#bslma_managedallocator-description}
41/// This component provides a protocol (pure abstract interface)
42/// class, `bslma::ManagedAllocator`, which extends the base-level protocol
43/// class, `bslma::Allocator`, providing the ability to `release` all memory
44/// currently allocated through the protocol back to the memory supplier of the
45/// derived concrete allocator object.
46/// @code
47/// ,-----------------------.
48/// ( bslma::ManagedAllocator )
49/// `-----------------------'
50/// | release
51/// V
52/// ,----------------.
53/// ( bslma::Allocator )
54/// `----------------'
55/// allocate
56/// deallocate
57/// @endcode
58///
59/// ## Usage {#bslma_managedallocator-usage}
60///
61///
62/// The `bslma::ManagedAllocator` protocol class serves as a useful internal
63/// interface for documentation purpose and could be used as a parameter to
64/// low-level helper functions for some implementations. We have yet to find a
65/// suitable real-world example and when one becomes available, it will be
66/// added.
67/// @}
68/** @} */
69/** @} */
70
71/** @addtogroup bsl
72 * @{
73 */
74/** @addtogroup bslma
75 * @{
76 */
77/** @addtogroup bslma_managedallocator
78 * @{
79 */
80
81#ifdef BDE_OPENSOURCE_PUBLICATION // DEPRECATED
82#error "bslma_managedallocator is deprecated"
83#endif
84#include <bslscm_version.h>
85
86#include <bslma_allocator.h>
87
88
89
90namespace bslma {
91
92 // ======================
93 // class ManagedAllocator
94 // ======================
95
96/// Provide a protocol for allocators with the ability to `release` all
97/// memory currently allocated through the protocol back to the memory
98/// supplier of the derived concrete allocator object.
99///
100/// See @ref bslma_managedallocator
102
103 private:
104 // PRIVATE ACCESSORS
105
106 /// Do nothing. Note that this function is added to avoid including a
107 /// (redundant) vtable into every translation unit that includes this
108 /// type. Although we expect that these redundant vtables, identified
109 /// by the `-Wweak-vtables` warning of the clang compiler (version 4.0
110 /// and higher), will be consolidated by the linker, this workaround
111 /// avoids the space being used in the generated object files, which may
112 /// be important for very heavily used types like this one.
113 /// Implementing a virtual function out-of-line enables the compiler to
114 /// use this component translation unit as a "home" for the single
115 /// shared copy of the vtable.
116 virtual void vtableDummy() const;
117
118 public:
119 // MANIPULATORS
120
121 /// Release all memory currently allocated through this allocator.
122 virtual void release() = 0;
123};
124
125} // close package namespace
126
127#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
128// ============================================================================
129// BACKWARD COMPATIBILITY
130// ============================================================================
131
132/// This alias is defined for backward compatibility.
134#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
135
136
137
138#endif
139
140// ----------------------------------------------------------------------------
141// Copyright 2013 Bloomberg Finance L.P.
142//
143// Licensed under the Apache License, Version 2.0 (the "License");
144// you may not use this file except in compliance with the License.
145// You may obtain a copy of the License at
146//
147// http://www.apache.org/licenses/LICENSE-2.0
148//
149// Unless required by applicable law or agreed to in writing, software
150// distributed under the License is distributed on an "AS IS" BASIS,
151// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152// See the License for the specific language governing permissions and
153// limitations under the License.
154// ----------------------------- END-OF-FILE ----------------------------------
155
156/** @} */
157/** @} */
158/** @} */
Definition bslma_allocator.h:457
Definition bslma_managedallocator.h:101
virtual void release()=0
Release all memory currently allocated through this allocator.
bslma::ManagedAllocator bslma_ManagedAllocator
This alias is defined for backward compatibility.
Definition bslma_managedallocator.h:133
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68