supereight
Loading...
Searching...
No Matches
memory_pool.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016-2019 Emanuele Vespa
3 * SPDX-FileCopyrightText: 2020-2024 Smart Robotics Lab, Imperial College London, Technical University of Munich
4 * SPDX-FileCopyrightText: 2020-2021 Nils Funk
5 * SPDX-FileCopyrightText: 2020-2024 Sotiris Papatheodorou
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef SE_MEMORY_POOL_HPP
10#define SE_MEMORY_POOL_HPP
11
12#include <Eigen/Core>
13#include <boost/pool/object_pool.hpp>
14
15namespace se {
16
27template<typename NodeT, typename BlockT>
29 public:
33 NodeT* allocateRoot(const Eigen::Vector3i& coord, const int size)
34 {
35 return new (node_buffer_.malloc()) NodeT(coord, size, typename NodeT::DataType());
36 }
37
42 const int child_idx,
43 const typename NodeT::DataType& init_data)
44 {
45 return new (node_buffer_.malloc()) NodeT(parent_ptr, child_idx, init_data);
46 }
47
52 const int child_idx,
53 const typename BlockT::DataType& init_data)
54 {
55 return new (block_buffer_.malloc()) BlockT(parent_ptr, child_idx, init_data);
56 }
57
60 {
61 node_buffer_.destroy(node_ptr);
62 }
63
66 {
67 block_buffer_.destroy(block_ptr);
68 }
69
70 private:
71 boost::object_pool<NodeT> node_buffer_;
72 boost::object_pool<BlockT> block_buffer_;
73};
74
75} // namespace se
76
77#endif // SE_MEMORY_POOL_HPP
Definition image.hpp:19
Manages memory for se::Octree nodes and blocks in an efficient manner.
Definition memory_pool.hpp:28
NodeT * allocateNode(NodeT *const parent_ptr, const int child_idx, const typename NodeT::DataType &init_data)
Return a pointer to a newly allocated node that is the child with index child_idx of parent_ptr and i...
Definition memory_pool.hpp:41
void deleteBlock(BlockT *const block_ptr)
Destruct and deallocate the block pointed to by block_ptr.
Definition memory_pool.hpp:65
BlockT * allocateBlock(NodeT *const parent_ptr, const int child_idx, const typename BlockT::DataType &init_data)
Return a pointer to a newly allocated block that is the child with index child_idx of parent_ptr and ...
Definition memory_pool.hpp:51
void deleteNode(NodeT *const node_ptr)
Destruct and deallocate the node pointed to by node_ptr.
Definition memory_pool.hpp:59
NodeT * allocateRoot(const Eigen::Vector3i &coord, const int size)
Allocate the root node with coordinates in voxels coord and edge length in voxels size.
Definition memory_pool.hpp:33
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14