Loading...
Searching...
No Matches
cell_constructors.h
Go to the documentation of this file.
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author(s): Hannah Schreiber
4 *
5 * Copyright (C) 2024 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
17#ifndef PM_COLUMN_CELL_CONSTRUCTORS_H
18#define PM_COLUMN_CELL_CONSTRUCTORS_H
19
20#include <utility> //std::swap
21
22#include <gudhi/Simple_object_pool.h>
23
24namespace Gudhi {
25namespace persistence_matrix {
26
34template <class Cell>
36{
41
48 template <class... U>
49 Cell* construct(U&&... u) const {
50 return new Cell(std::forward<U>(u)...);
51 }
52
58 void destroy(Cell* cell) const { delete cell; }
59
63 friend void swap(New_cell_constructor& col1, New_cell_constructor& col2) {}
64};
65
74template <class Cell>
76{
77 public:
82 Pool_cell_constructor() : cellPool_() {}
83 //TODO: what does happen when the pool is copied?
89 Pool_cell_constructor(const Pool_cell_constructor& col) : cellPool_(col.cellPool_) {}
95 Pool_cell_constructor(Pool_cell_constructor&& col) : cellPool_(std::move(col.cellPool_)) {}
96
103 template <class... U>
104 Cell* construct(U&&... u) {
105 return cellPool_.construct(std::forward<U>(u)...);
106 }
107
113 void destroy(Cell* cell) { cellPool_.destroy(cell); }
114
115 //TODO: Again, what does it mean to copy the pool?
120 cellPool_ = other.cellPool_;
121 return *this;
122 }
127 std::swap(col1.cellPool_, col2.cellPool_);
128 }
129
130 private:
131 Simple_object_pool<Cell> cellPool_;
132};
133
134} // namespace persistence_matrix
135} // namespace Gudhi
136
137#endif // PM_COLUMN_CELL_CONSTRUCTORS_H
Matrix cell class. Stores by default only the row index it belongs to, but can also store its column ...
Definition cell_types.h:193
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14
Cell factory. Constructs and destroyes cell pointers with new and delete.
Definition cell_constructors.h:36
friend void swap(New_cell_constructor &col1, New_cell_constructor &col2)
Swap operator.
Definition cell_constructors.h:63
void destroy(Cell *cell) const
Destroyes the given cell.
Definition cell_constructors.h:58
Cell * construct(U &&... u) const
Constructs a cell with the given cell arguments.
Definition cell_constructors.h:49
New_cell_constructor()
Default constructor.
Definition cell_constructors.h:40
Cell factory. Uses Gudhi::Simple_object_pool, which is based on boost::object_pool,...
Definition cell_constructors.h:76
Pool_cell_constructor(Pool_cell_constructor &&col)
Move constructor.
Definition cell_constructors.h:95
Pool_cell_constructor & operator=(const Pool_cell_constructor &other)
Assign operator.
Definition cell_constructors.h:119
Pool_cell_constructor(const Pool_cell_constructor &col)
Copy constructor.
Definition cell_constructors.h:89
void destroy(Cell *cell)
Destroyes the given cell.
Definition cell_constructors.h:113
Cell * construct(U &&... u)
Constructs a cell with the given cell arguments.
Definition cell_constructors.h:104
friend void swap(Pool_cell_constructor &col1, Pool_cell_constructor &col2)
Swap operator.
Definition cell_constructors.h:126
Pool_cell_constructor()
Default constructor.
Definition cell_constructors.h:82