entry_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_ENTRY_CONSTRUCTORS_H
18#define PM_COLUMN_ENTRY_CONSTRUCTORS_H
19
20#include <utility> //std::swap
21
22#include <gudhi/Simple_object_pool.h>
23
24namespace Gudhi {
25namespace persistence_matrix {
26
35template <class Entry>
36struct New_entry_constructor
37{
41 New_entry_constructor() {}
42
49 template <class... U>
50 Entry* construct(U&&... u) const {
51 return new Entry(std::forward<U>(u)...);
52 }
53
59 void destroy(Entry* entry) const { delete entry; }
60
64 friend void swap(New_entry_constructor& col1, New_entry_constructor& col2) {}
65};
66
76template <class Entry>
77struct Pool_entry_constructor
78{
79 public:
84 Pool_entry_constructor() : entryPool_() {}
85 //TODO: what does happen when the pool is copied?
91 Pool_entry_constructor(const Pool_entry_constructor& col) : entryPool_(col.entryPool_) {}
97 Pool_entry_constructor(Pool_entry_constructor&& col) : entryPool_(std::move(col.entryPool_)) {}
98
105 template <class... U>
106 Entry* construct(U&&... u) {
107 return entryPool_.construct(std::forward<U>(u)...);
108 }
109
115 void destroy(Entry* entry) { entryPool_.destroy(entry); }
116
117 //TODO: Again, what does it mean to copy the pool?
121 Pool_entry_constructor& operator=(const Pool_entry_constructor& other) {
122 entryPool_ = other.entryPool_;
123 return *this;
124 }
128 friend void swap(Pool_entry_constructor& col1, Pool_entry_constructor& col2) {
129 std::swap(col1.entryPool_, col2.entryPool_);
130 }
131
132 private:
133 Simple_object_pool<Entry> entryPool_;
134};
135
136} // namespace persistence_matrix
137} // namespace Gudhi
138
139#endif // PM_COLUMN_ENTRY_CONSTRUCTORS_H
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
STL namespace.