Loading...
Searching...
No Matches
Simplex_tree_node_explicit_storage.h
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): Clément Maria
4 *
5 * Copyright (C) 2014 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
11#ifndef SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
12#define SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
13
14// Empty base optimization for MSVC - https://learn.microsoft.com/en-us/cpp/cpp/empty-bases
15#if _MSC_VER
16 #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION __declspec(empty_bases)
17#else
18 #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION
19#endif
20
21#include <boost/core/empty_value.hpp>
22
23namespace Gudhi {
24
29
35template <class SimplexTree>
36struct GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION Simplex_tree_node_explicit_storage
37 : SimplexTree::Filtration_simplex_base,
38 SimplexTree::Key_simplex_base,
39 SimplexTree::Hooks_simplex_base,
40 boost::empty_value<typename SimplexTree::Simplex_data> {
41 typedef typename SimplexTree::Siblings Siblings;
42 typedef typename SimplexTree::Filtration_value Filtration_value;
43 typedef typename SimplexTree::Simplex_key Simplex_key;
44 typedef typename SimplexTree::Simplex_data Simplex_data;
45
46 Simplex_tree_node_explicit_storage() : children_(nullptr) {}
47
48 Simplex_tree_node_explicit_storage(Siblings* sib, const Filtration_value& filtration = Filtration_value())
49 : SimplexTree::Filtration_simplex_base(filtration), children_(sib)
50 {}
51
52 //will fail to compile when called with SimplexTree::Options::store_key is false.
53 Simplex_tree_node_explicit_storage(Siblings* sib, Filtration_value filtration, Simplex_key key)
54 : SimplexTree::Filtration_simplex_base(filtration), SimplexTree::Key_simplex_base(key), children_(sib)
55 {}
56
57 /*
58 * Assign children to the node
59 */
60 void assign_children(Siblings * children) {
61 children_ = children;
62 }
63
64 /* Careful -> children_ can be NULL*/
65 Siblings * children() {
66 return children_;
67 }
68 const Siblings * children() const {
69 return children_;
70 }
71
72 Simplex_data& data() { return boost::empty_value<Simplex_data>::get(); }
73 const Simplex_data& data() const { return boost::empty_value<Simplex_data>::get(); }
74
75 private:
76 Siblings * children_;
77};
78 // end addtogroup simplex_tree
80
81} // namespace Gudhi
82
83#endif // SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
Options::Filtration_value Filtration_value
Type for the value of the filtration function.
Definition Simplex_tree.h:108
Options::Simplex_key Simplex_key
Key associated to each simplex.
Definition Simplex_tree.h:112
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition Simplex_tree.h:139
Get_simplex_data_type< Options >::type Simplex_data
Extra data stored in each simplex.
Definition Simplex_tree.h:118
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14