Loading...
Searching...
No Matches
entry_constructors.h
Go to the documentation of this file.
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2024 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef PM_COLUMN_ENTRY_CONSTRUCTORS_H
#define PM_COLUMN_ENTRY_CONSTRUCTORS_H
#include <utility> //std::swap
#include <gudhi/Simple_object_pool.h>
namespace Gudhi {
namespace persistence_matrix {
template <class Entry>
struct New_entry_constructor
{
New_entry_constructor() {}
template <class... U>
Entry* construct(U&&... u) const {
return new Entry(std::forward<U>(u)...);
}
void destroy(Entry* entry) const { delete entry; }
friend void swap(New_entry_constructor& col1, New_entry_constructor& col2) {}
};
template <class Entry>
struct Pool_entry_constructor
{
public:
Pool_entry_constructor() : entryPool_() {}
//TODO: what does happen when the pool is copied?
Pool_entry_constructor(const Pool_entry_constructor& col) : entryPool_(col.entryPool_) {}
Pool_entry_constructor(Pool_entry_constructor&& col) : entryPool_(std::move(col.entryPool_)) {}
template <class... U>
Entry* construct(U&&... u) {
return entryPool_.construct(std::forward<U>(u)...);
}
void destroy(Entry* entry) { entryPool_.destroy(entry); }
//TODO: Again, what does it mean to copy the pool?
Pool_entry_constructor& operator=(const Pool_entry_constructor& other) {
entryPool_ = other.entryPool_;
return *this;
}
friend void swap(Pool_entry_constructor& col1, Pool_entry_constructor& col2) {
std::swap(col1.entryPool_, col2.entryPool_);
}
private:
Simple_object_pool<Entry> entryPool_;
};
} // namespace persistence_matrix
} // namespace Gudhi
#endif // PM_COLUMN_ENTRY_CONSTRUCTORS_H
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14