Wildmeshing Toolkit
CachingAccessor.hxx
Go to the documentation of this file.
1 #pragma once
2 
4 #include "AttributeScope.hpp"
6 #include "CachingAccessor.hpp"
7 
8 namespace wmtk::attribute {
9 
10 template <typename T, int Dim>
12  Mesh& mesh_in,
13  const TypedAttributeHandle<T>& handle)
14  : BaseType(mesh_in, handle)
15  , m_cache_stack(attribute().get_local_scope_stack())
16 {}
17 template <typename T, int Dim>
19  : BaseType(mesh_in, handle)
20  , m_cache_stack(attribute().get_local_scope_stack())
21 {}
22 
23 template <typename T, int Dim>
25 
26 template <typename T, int Dim>
28 {
29  return !m_cache_stack.empty();
30 }
31 
32 template <typename T, int Dim>
34 {
35  return m_cache_stack.writing_enabled();
36 }
37 
38 template <typename T, int Dim>
40 {
41  return m_cache_stack.size();
42 }
43 
44 template <typename T, int Dim>
45 template <int D>
46 inline auto CachingAccessor<T, Dim>::vector_attribute(const int64_t index) -> MapResult<D>
47 {
48  return m_cache_stack.template vector_attribute<D>(*this, index);
49  // return BaseType::template vector_attribute<D>( index);
50 }
51 
52 
53 template <typename T, int Dim>
54 inline auto CachingAccessor<T, Dim>::scalar_attribute(const int64_t index) -> T&
55 {
56  return m_cache_stack.scalar_attribute(*this, index);
57 }
58 
59 template <typename T, int Dim>
60 template <int D>
61 inline auto CachingAccessor<T, Dim>::const_vector_attribute(const int64_t index) const
63 {
64  return m_cache_stack.template const_vector_attribute<D>(*this, index);
65 }
66 
67 
68 template <typename T, int Dim>
69 inline auto CachingAccessor<T, Dim>::const_scalar_attribute(const int64_t index) const -> T
70 {
71  return m_cache_stack.const_scalar_attribute(*this, index);
72 }
73 
74 template <typename T, int Dim>
75 inline auto CachingAccessor<T, Dim>::vector_attribute(const int64_t index) const -> ConstMapResult<>
76 {
77  return const_vector_attribute(index);
78 }
79 template <typename T, int Dim>
80 inline T CachingAccessor<T, Dim>::scalar_attribute(const int64_t index) const
81 {
82  return const_scalar_attribute(index);
83 }
84 
85 template <typename T, int Dim>
86 inline auto CachingAccessor<T, Dim>::scalar_attribute(const int64_t index, int8_t offset) -> T&
87 {
88  return m_cache_stack.scalar_attribute(*this, index, offset);
89 }
90 
91 
92 template <typename T, int Dim>
93 inline auto CachingAccessor<T, Dim>::const_scalar_attribute(const int64_t index, int8_t offset)
94  const -> T
95 {
96  return m_cache_stack.const_scalar_attribute(*this, index, offset);
97 }
98 
99 // template class CachingAccessor<char>;
100 // template class CachingAccessor<int64_t>;
101 // template class CachingAccessor<double>;
102 // template class CachingAccessor<Rational>;
103 } // namespace wmtk::attribute
internal::ConstMapResult< T, D > ConstMapResult
typename BaseType::template MapResult< D > MapResult
typename BaseType::template ConstMapResult< D > ConstMapResult
T const_scalar_attribute(const int64_t index) const
MapResult< D > vector_attribute(const int64_t index)
T & scalar_attribute(const int64_t index)
CachingAccessor(Mesh &m, const TypedAttributeHandle< T > &handle)
ConstMapResult< D > const_vector_attribute(const int64_t index) const
Handle that represents attributes for some mesh.