Embedded Template Library 1.0
variant_pool.h
1/******************************************************************************
2The MIT License(MIT)
3
4Embedded Template Library.
5https://github.com/ETLCPP/etl
6https://www.etlcpp.com
7
8Copyright(c) 2017 John Wellbelove
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files(the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions :
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27******************************************************************************/
28
29#if 0
30#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
31#endif
32
33//***************************************************************************
34// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
35//***************************************************************************
36
37//***************************************************************************
38// To generate to header file, run this at the command line.
39// Note: You will need Python and COG installed.
40//
41// python -m cogapp -d -e -ovariant_pool.h -DNTypes=<n> variant_pool_generator.h
42// Where <n> is the number of types to support.
43//
44// e.g.
45// To generate handlers for up to 16 types...
46// python -m cogapp -d -e -ovariant_pool.h -DNTypes=16 variant_pool_generator.h
47//
48// See generate.bat
49//***************************************************************************
50
51#ifndef ETL_VARIANT_POOL_INCLUDED
52#define ETL_VARIANT_POOL_INCLUDED
53
54#include "platform.h"
55#include "pool.h"
56#include "type_traits.h"
57#include "static_assert.h"
58#include "largest.h"
59
60#include <stdint.h>
61
62namespace etl
63{
64 //***************************************************************************
65 template <size_t MAX_SIZE_,
66 typename T1,
67 typename T2 = void,
68 typename T3 = void,
69 typename T4 = void,
70 typename T5 = void,
71 typename T6 = void,
72 typename T7 = void,
73 typename T8 = void,
74 typename T9 = void,
75 typename T10 = void,
76 typename T11 = void,
77 typename T12 = void,
78 typename T13 = void,
79 typename T14 = void,
80 typename T15 = void,
81 typename T16 = void>
83 : public etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
84 etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
85 MAX_SIZE_>
86 {
87 public:
88
91 MAX_SIZE_> base_t;
92
93 static const size_t MAX_SIZE = MAX_SIZE_;
94
95 //*************************************************************************
97 //*************************************************************************
99 {
100 }
101
102#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
103 //*************************************************************************
105 //*************************************************************************
106 template <typename T>
108 {
110
111 return base_t::template create<T>();
112 }
113
114 //*************************************************************************
116 //*************************************************************************
117 template <typename T, typename TP1>
118 T* create(const TP1& p1)
119 {
121
122 return base_t::template create<T>(p1);
123 }
124
125 //*************************************************************************
127 //*************************************************************************
128 template <typename T, typename TP1, typename TP2>
129 T* create(const TP1& p1, const TP2& p2)
130 {
132
133 return base_t::template create<T>(p1, p2);
134 }
135
136 //*************************************************************************
138 //*************************************************************************
139 template <typename T, typename TP1, typename TP2, typename TP3>
140 T* create(const TP1& p1, const TP2& p2, const TP3& p3)
141 {
143
144 return base_t::template create<T>(p1, p2, p3);
145 }
146
147 //*************************************************************************
149 //*************************************************************************
150 template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
151 T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
152 {
154
155 return base_t::template create<T>(p1, p2, p3, p4);
156 }
157#else
158 //*************************************************************************
160 //*************************************************************************
161 template <typename T, typename... Args>
162 T* create(Args&&... args)
163 {
165
166 return base_t::template create<T>(etl::forward<Args>(args)...);
167 }
168#endif
169
170 //*************************************************************************
172 //*************************************************************************
173 template <typename T>
174 void destroy(const T* const p)
175 {
192 etl::is_base_of<T, T16>::value), "Invalid type");
193
195 }
196
197 //*************************************************************************
199 //*************************************************************************
200 size_t max_size() const
201 {
202 return MAX_SIZE;
203 }
204
205 private:
206
207 variant_pool(const variant_pool&) ETL_DELETE;
208 variant_pool& operator =(const variant_pool&) ETL_DELETE;
209 };
210
211 //***************************************************************************
212 template <typename T1,
213 typename T2 = void,
214 typename T3 = void,
215 typename T4 = void,
216 typename T5 = void,
217 typename T6 = void,
218 typename T7 = void,
219 typename T8 = void,
220 typename T9 = void,
221 typename T10 = void,
222 typename T11 = void,
223 typename T12 = void,
224 typename T13 = void,
225 typename T14 = void,
226 typename T15 = void,
227 typename T16 = void>
229 : public etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
230 etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment>
231 {
232 public:
233
236
237 //*************************************************************************
239 //*************************************************************************
240 variant_pool_ext(typename base_t::element* buffer, size_t size)
241 : base_t(buffer, size)
242 {
243 }
244
245#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
246 //*************************************************************************
248 //*************************************************************************
249 template <typename T>
251 {
253
254 return base_t::template create<T>();
255 }
256
257 //*************************************************************************
259 //*************************************************************************
260 template <typename T, typename TP1>
261 T* create(const TP1& p1)
262 {
264
265 return base_t::template create<T>(p1);
266 }
267
268 //*************************************************************************
270 //*************************************************************************
271 template <typename T, typename TP1, typename TP2>
272 T* create(const TP1& p1, const TP2& p2)
273 {
275
276 return base_t::template create<T>(p1, p2);
277 }
278
279 //*************************************************************************
281 //*************************************************************************
282 template <typename T, typename TP1, typename TP2, typename TP3>
283 T* create(const TP1& p1, const TP2& p2, const TP3& p3)
284 {
286
287 return base_t::template create<T>(p1, p2, p3);
288 }
289
290 //*************************************************************************
292 //*************************************************************************
293 template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
294 T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
295 {
297
298 return base_t::template create<T>(p1, p2, p3, p4);
299 }
300#else
301 //*************************************************************************
303 //*************************************************************************
304 template <typename T, typename... Args>
305 T* create(Args&&... args)
306 {
308
309 return base_t::template create<T>(etl::forward<Args>(args)...);
310 }
311#endif
312
313 //*************************************************************************
315 //*************************************************************************
316 template <typename T>
317 void destroy(const T* const p)
318 {
335 etl::is_base_of<T, T16>::value), "Invalid type");
336
338 }
339
340 //*************************************************************************
342 //*************************************************************************
343 size_t max_size() const
344 {
345 return base_t::max_size();
346 }
347
348 private:
349
350 variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
351 variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
352 };
353}
354
355#endif
Definition: variant_pool.h:231
T * create(const TP1 &p1, const TP2 &p2)
Creates the object. Two parameter constructor.
Definition: variant_pool.h:272
T * create(const TP1 &p1, const TP2 &p2, const TP3 &p3, const TP4 &p4)
Creates the object. Four parameter constructor.
Definition: variant_pool.h:294
T * create()
Creates the object. Default constructor.
Definition: variant_pool.h:250
void destroy(const T *const p)
Destroys the object.
Definition: variant_pool.h:317
T * create(const TP1 &p1)
Creates the object. One parameter constructor.
Definition: variant_pool.h:261
T * create(const TP1 &p1, const TP2 &p2, const TP3 &p3)
Creates the object. Three parameter constructor.
Definition: variant_pool.h:283
variant_pool_ext(typename base_t::element *buffer, size_t size)
Default constructor.
Definition: variant_pool.h:240
size_t max_size() const
Returns the maximum number of items in the variant_pool.
Definition: variant_pool.h:343
Definition: variant_pool.h:86
size_t max_size() const
Returns the maximum number of items in the variant_pool.
Definition: variant_pool.h:200
void destroy(const T *const p)
Destroys the object.
Definition: variant_pool.h:174
T * create(const TP1 &p1)
Creates the object. One parameter constructor.
Definition: variant_pool.h:118
T * create()
Creates the object. Default constructor.
Definition: variant_pool.h:107
variant_pool()
Default constructor.
Definition: variant_pool.h:98
T * create(const TP1 &p1, const TP2 &p2, const TP3 &p3, const TP4 &p4)
Creates the object. Four parameter constructor.
Definition: variant_pool.h:151
T * create(const TP1 &p1, const TP2 &p2)
Creates the object. Two parameter constructor.
Definition: variant_pool.h:129
T * create(const TP1 &p1, const TP2 &p2, const TP3 &p3)
Creates the object. Three parameter constructor.
Definition: variant_pool.h:140
Definition: largest.h:367
size_t size() const
Returns the number of allocated items in the pool.
Definition: ipool.h:293
size_t max_size() const
Returns the maximum number of items in the pool.
Definition: ipool.h:269
void destroy(const U *const p_object)
Definition: generic_pool.h:169
void destroy(const U *const p_object)
Definition: generic_pool.h:337
Definition: generic_pool.h:56
Definition: generic_pool.h:213
is_base_of
Definition: type_traits_generator.h:1252
bitset_ext
Definition: absolute.h:38
Definition: alignment.h:223
Definition: type_traits.h:1376