Wildmeshing Toolkit
AttributeScope.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include "Attribute.hpp"
6 #include "AttributeCache.hpp"
7 
8 namespace wmtk {
9 
10 
11 namespace attribute {
12 template <typename T, int Dim>
13 class CachingAccessor;
14 
15 template <typename T>
16 class AttributeScope : public AttributeCache<T>
17 {
18 public:
19  template <typename U, int D>
20  friend class CachingAccessor;
22  AttributeScope(const AttributeScope&) = delete;
27  AttributeScope(std::unique_ptr<AttributeScope<T>>&& next);
28 
30  // flushes cache to previous scope unless there is no previous scope, in which
31  // case it flushes data to the underlying attribute storage
32  void apply(Attribute<T>& attr) const;
33 
34  void apply(const Attribute<T>& attr, std::vector<T>& data);
35 
36 private:
39 
40  template <int Dim>
42  const;
43  template <int Dim>
44  T load_const_cached_scalar_value(const AccessorBase<T>& accessor, int64_t index) const;
45 
46  AttributeCache<T>& get_cache() { return static_cast<AttributeCache<T>&>(*this); }
47 };
48 
49 } // namespace attribute
50 } // namespace wmtk
51 #include "AttributeScope.hxx"
This class stores data of type T in a vector.
Definition: Attribute.hpp:32
AttributeScope & operator=(const AttributeScope &)=delete
AttributeScope(std::unique_ptr< AttributeScope< T >> &&next)
ConstMapResult load_const_cached_vector_value(const AccessorBase< T, Dim > &accessor, int64_t index) const
AttributeScope & operator=(AttributeScope &&)=default
AttributeScope(AttributeScope &&)=default
typename AttributeCache< T >::MapResult MapResult
typename AttributeCache< T >::ConstMapResult ConstMapResult
AttributeScope(const AttributeScope &)=delete
AttributeCache< T > & get_cache()
T load_const_cached_scalar_value(const AccessorBase< T > &accessor, int64_t index) const
void apply(Attribute< T > &attr) const
An accessor for cached attribute values.
Definition: Accessor.hpp:6