ATLAS Offline Software
Loading...
Searching...
No Matches
DataPool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHALLOCATORS_DATAPOOL_H
6#define ATHALLOCATORS_DATAPOOL_H
36
39#include <string>
40#include "boost/iterator/iterator_adaptor.hpp"
41
42
43namespace SG {
44
45
50template <class VALUE>
52{
53public:
54 static void clear (VALUE*) {}
55};
56
57
58} // namespace SG
59
60
61template <typename VALUE, typename CLEAR = SG::DataPoolNullClear<VALUE> >
63{
64private:
67
68public:
69 typedef typename handle_t::pointer pointer;
70 typedef size_t size_type;
71
72 class const_iterator;
73
75 : public boost::iterator_adaptor<
76 iterator,
77 typename handle_t::iterator,
78 VALUE *,
79 boost::forward_traversal_tag,
80 VALUE *>
81 {
82 public:
83 iterator (const typename handle_t::iterator& it)
84 : iterator::iterator_adaptor_ (it)
85 {
86 }
87
88 friend class const_iterator;
89
90 private:
92
94 { return &*this->base_reference(); }
95 };
96
98 : public boost::iterator_adaptor<
99 const_iterator,
100 typename handle_t::const_iterator,
101 VALUE const *,
102 boost::forward_traversal_tag,
103 VALUE const *>
104 {
105 public:
107 : const_iterator::iterator_adaptor_ (it)
108 {
109 }
110
112 : const_iterator::iterator_adaptor_ (it.base_reference())
113 {
114 }
115
116 private:
118
120 { return &*this->base_reference(); }
121 };
122
123
127
129
130 DataPool(const EventContext& ctx,
131 size_type n = 0);
132
134 size_type n = 0);
135
137
139 void reset();
140
142 void erase();
143
156 void reserve(unsigned int size);
157
168 void prepareToAdd(unsigned int size);
169
171 unsigned int capacity();
172
174 unsigned int allocated();
175
177 iterator begin();
178 const_iterator begin() const;
179
182 iterator end();
183 const_iterator end() const;
184
190
192 static const std::string& typeName();
193
194//-----------------------------------------------------------//
195
196 private:
197
199
200 const static typename alloc_t::Params s_params;
201
203 static constexpr size_t s_minRefCount = 1024;
204
205 static typename alloc_t::Params initParams();
207};
208
209
211
212#endif
213
214
User interface for allocating memory that caches constructed objects. See Arena.h for an overview of ...
Pool-based allocator. See Arena.h for an overview of the arena-based memory allocators.
CONT::reference reference
const_iterator(const typename handle_t::const_iterator &it)
Definition DataPool.h:106
friend class boost::iterator_core_access
Definition DataPool.h:117
const_iterator::reference dereference() const
Definition DataPool.h:119
const_iterator(const iterator &it)
Definition DataPool.h:111
iterator::reference dereference() const
Definition DataPool.h:93
friend class boost::iterator_core_access
Definition DataPool.h:91
friend class const_iterator
Definition DataPool.h:88
iterator(const typename handle_t::iterator &it)
Definition DataPool.h:83
void reserve(unsigned int size)
Set the desired capacity.
static alloc_t::Params initParams()
DataPool(SG::Arena *arena, size_type n=0)
handle_t::pointer pointer
Definition DataPool.h:69
DataPool(const EventContext &ctx, size_type n=0)
DataPool(size_type n=0)
Constructors:
static const alloc_t::Params s_params
Definition DataPool.h:200
void erase()
free all memory in the pool.
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
size_t size_type
Definition DataPool.h:70
static void callClear(SG::ArenaAllocatorBase::pointer p)
unsigned int capacity()
return capacity of pool OK
SG::ArenaCachingHandle< VALUE, alloc_t > handle_t
Definition DataPool.h:66
unsigned int allocated()
return size already allocated OK
void prepareToAdd(unsigned int size)
Prepare to add cached elements.
iterator end()
the end() method will allow looping over only valid elements and not over ALL elements of the pool
SG::ArenaPoolAllocator alloc_t
Definition DataPool.h:65
void reset()
release all elements in the pool.
const_iterator end() const
iterator begin()
begin iterators over pool
const_iterator begin() const
static const std::string & typeName()
typename of pool
static constexpr size_t s_minRefCount
Definition DataPool.h:203
char * pointer
Type for pointers to elements.
User interface for allocating memory that caches constructed objects.
Pool-based allocator.
Collection of memory allocators with a common lifetime,.
Definition Arena.h:238
Null cleanup functional — does no actual cleanup.
Definition DataPool.h:52
static void clear(VALUE *)
Definition DataPool.h:54
#define VALUE(TESTED)
Definition expect.h:59
Forward declaration.