Wildmeshing Toolkit
AttributeHandle.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <cstdint>
3 #include <type_traits>
4 
5 // TODO: is this abstraction still necessary? the original attempt was to have a generic index that
6 // avoided passing templates around, but in the end we still obtained a TypedAttributeHandle<T> and
7 // used variant to remove the templating + introduce multimesh
8 
9 namespace wmtk {
10 template <typename T>
11 class hash;
12 class Mesh;
13 namespace attribute {
14 template <typename T>
15 class MeshAttributes;
16 template <typename T>
18 class AttributeManager;
19 
24 {
25 protected:
26 public:
27  template <typename T>
28  friend class MeshAttributes;
29  template <typename T>
30  friend class TypedAttributeHandle;
31  friend class AttributeManager;
32  friend class wmtk::hash<AttributeHandle>;
33  friend class Mesh;
34 
35  int64_t index = -1;
36  AttributeHandle(int64_t i) noexcept
37  : index(i)
38  {}
39 
40 public:
41  AttributeHandle() = default;
42  AttributeHandle(const AttributeHandle&) = default;
46 
47 
48  bool operator==(const AttributeHandle& other) const noexcept { return index == other.index; }
49  bool operator<(const AttributeHandle& other) const noexcept { return index < other.index; }
50 
51  bool is_valid() const noexcept { return index != -1; }
52 };
53 
54 } // namespace attribute
56 } // namespace wmtk
Internal handle representation used by MeshAttributes.
bool operator<(const AttributeHandle &other) const noexcept
AttributeHandle(AttributeHandle &&)=default
AttributeHandle & operator=(const AttributeHandle &)=default
AttributeHandle(const AttributeHandle &)=default
bool operator==(const AttributeHandle &other) const noexcept
AttributeHandle & operator=(AttributeHandle &&)=default
Contains all attributes of type T for a single mesh.
Handle that represents attributes for some mesh.
Definition: Accessor.hpp:6
attribute::TypedAttributeHandle< T > TypedAttributeHandle
attribute::AttributeHandle AttributeHandle