supereight
Loading...
Searching...
No Matches
null_memory_pool.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Smart Robotics Lab, Imperial College London, Technical University of Munich
3 * SPDX-FileCopyrightText: 2024 Sotiris Papatheodorou
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SE_NULL_MEMORY_POOL_HPP
8#define SE_NULL_MEMORY_POOL_HPP
9
10#include <Eigen/Core>
11#include <set>
12
13namespace se {
14
20template<typename NodeT, typename BlockT>
22 public:
24 {
25 for (NodeT* const p : node_buffer_) {
26 delete p;
27 }
28 for (BlockT* const p : block_buffer_) {
29 delete p;
30 }
31 }
32
33 NodeT* allocateRoot(const Eigen::Vector3i& coord, const int size)
34 {
35 auto [it, _] = node_buffer_.emplace(new NodeT(coord, size, typename NodeT::DataType()));
36 return *it;
37 }
38
40 const int child_idx,
41 const typename NodeT::DataType& init_data)
42 {
43 auto [it, _] = node_buffer_.emplace(new NodeT(parent_ptr, child_idx, init_data));
44 return *it;
45 }
46
48 const int child_idx,
49 const typename BlockT::DataType& init_data)
50 {
51 auto [it, _] = block_buffer_.emplace(new BlockT(parent_ptr, child_idx, init_data));
52 return *it;
53 }
54
56 {
57 delete node_ptr;
58 node_buffer_.erase(node_ptr);
59 }
60
62 {
63 delete block_ptr;
64 block_buffer_.erase(block_ptr);
65 }
66
67 private:
68 std::set<NodeT*> node_buffer_;
69 std::set<BlockT*> block_buffer_;
70};
71
72} // namespace se
73
74#endif // SE_NULL_MEMORY_POOL_HPP
Definition image.hpp:19
An alternate implementation of se::MemoryPool that can help debug certain memory-related bugs.
Definition null_memory_pool.hpp:21
BlockT * allocateBlock(NodeT *const parent_ptr, const int child_idx, const typename BlockT::DataType &init_data)
Definition null_memory_pool.hpp:47
NodeT * allocateRoot(const Eigen::Vector3i &coord, const int size)
Definition null_memory_pool.hpp:33
void deleteBlock(BlockT *const block_ptr)
Definition null_memory_pool.hpp:61
NodeT * allocateNode(NodeT *const parent_ptr, const int child_idx, const typename NodeT::DataType &init_data)
Definition null_memory_pool.hpp:39
void deleteNode(NodeT *const node_ptr)
Definition null_memory_pool.hpp:55
~NullMemoryPool()
Definition null_memory_pool.hpp:23
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14