BDE 4.39.x 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.
107 /// \note Note that this function is added to avoid including a
108 /// (redundant) vtable into every translation unit that includes this
109 /// type. Although we expect that these redundant vtables, identified
110 /// by the `-Wweak-vtables` warning of the clang compiler (version 4.0
111 /// and higher), will be consolidated by the linker, this workaround
112 /// avoids the space being used in the generated object files, which may
113 /// be important for very heavily used types like this one.
114 /// Implementing a virtual function out-of-line enables the compiler to
115 /// use this component translation unit as a "home" for the single
116 /// shared copy of the vtable.
117 virtual void vtableDummy() const;
118
119 public:
120 // MANIPULATORS
121
122 /// Release all memory currently allocated through this allocator.
123 virtual void release() = 0;
124};
125
126} // close package namespace
127
128#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
129// ============================================================================
130// BACKWARD COMPATIBILITY
131// ============================================================================
132
133/// This alias is defined for backward compatibility.
135#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
136
137
138
139#endif
140
141// ----------------------------------------------------------------------------
142// Copyright 2013 Bloomberg Finance L.P.
143//
144// Licensed under the Apache License, Version 2.0 (the "License");
145// you may not use this file except in compliance with the License.
146// You may obtain a copy of the License at
147//
148// http://www.apache.org/licenses/LICENSE-2.0
149//
150// Unless required by applicable law or agreed to in writing, software
151// distributed under the License is distributed on an "AS IS" BASIS,
152// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
153// See the License for the specific language governing permissions and
154// limitations under the License.
155// ----------------------------- END-OF-FILE ----------------------------------
156
157/** @} */
158/** @} */
159/** @} */
Definition bslma_allocator.h:545
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:134
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition baljsn_encoder_testtypes.h:76