29 #ifndef DATATOOLS_HANDLE_POOL_H 30 #define DATATOOLS_HANDLE_POOL_H 80 void dump(std::ostream & out_ = std::clog,
81 const std::string & title_ =
"",
82 const std::string & indent_ =
"",
83 bool abridged_ =
true)
const;
101 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 104 _number_of_used_item_ = 0;
105 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 111 template <
typename T>
114 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 117 _number_of_used_item_ = 0;
118 this->resize_impl(size_);
119 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 125 template <
typename T>
128 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 133 _number_of_used_item_ = 0;
135 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 142 template <
typename T>
150 template <
typename T>
153 return _buffer_.size();
157 template <
typename T>
160 return _number_of_used_item_;
164 template <
typename T>
167 _number_of_used_item_ = 0;
172 template <
typename T>
177 "Cannot resize pool with items in use");
178 this->resize_impl(size_);
183 template <
typename T>
186 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 192 if (_number_of_used_item_ < _buffer_.size()) {
193 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 195 << _number_of_used_item_);
198 return _buffer_[_number_of_used_item_++];
203 _number_of_used_item_++;
204 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 206 << (_number_of_used_item_ - 1));
209 return _buffer_.back();
213 template <
typename T>
215 const std::string & title_,
216 const std::string & indent_,
217 bool abridged_)
const {
218 if (!title_.empty()) {
219 out_ << indent_ << title_ <<
" : " << std::endl;
221 out_ << indent_ <<
"|-- " <<
"Capacity : " << this->get_capacity() << std::endl;
222 out_ << indent_ <<
"|-- " <<
"# Used items : " << _number_of_used_item_ << std::endl;
223 out_ << indent_ <<
"`-- " <<
"Items @ " << std::endl;
224 for (
size_t i = 0; i < _buffer_.size(); ++i) {
226 if (i >= 10)
continue;
228 out_ << indent_ <<
" ";
230 if (i < _buffer_.size() - 1) {
235 out_ <<
"index " << i <<
" : ";
237 out_ <<
"No element!" << std::endl;
239 out_ <<
"@ " << &h.
get() <<
" [unique=" << h.
unique() <<
"]"<< std::endl;
246 template <
typename T>
248 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 252 size_t current_size = _buffer_.size();
254 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 258 if (size_ <= current_size) {
259 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 265 _buffer_.reserve(size_);
266 for (
size_t i = current_size; i < size_; ++i) {
267 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 273 _number_of_used_item_ = 0;
275 #ifdef DATATOOLS_HANDLE_POOL_DEVEL 284 #endif // DATATOOLS_HANDLE_POOL_H #define DT_LOG_TRACE_EXITING(Priority)
Log a fonction exiting message if Priority is greater or equal to PRIO_TRACE.
Definition: logger_macros.h:267
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
#define DT_LOG_TRACE(Priority, Message)
Log Message if Priority is greater or equal to PRIO_TRACE.
Definition: logger_macros.h:227
#define DT_LOG_TRACE_ENTERING(Priority)
Log a fonction entering message if Priority is greater or equal to PRIO_TRACE.
Definition: logger_macros.h:261