Wildmeshing Toolkit
Loading...
Searching...
No Matches
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
9namespace wmtk {
10namespace attribute {
11template <typename T>
12class TypedAttributeManager;
13template <typename T>
15class AttributeManager;
16
21{
22protected:
23private:
24 template <typename T>
26 template <typename T>
28 friend class AttributeManager;
29
30 // Index of the attribute in the TypedAttributeHandle
31 int64_t m_index = -1;
32 AttributeHandle(int64_t i) noexcept
33 : m_index(i)
34 {}
36 {
37 m_index = i;
38 return *this;
39 }
40
41
42public:
43 AttributeHandle() = default;
48
49
50 bool operator==(const AttributeHandle& other) const noexcept
51 {
52 return m_index == other.m_index;
53 }
54 bool operator<(const AttributeHandle& other) const noexcept { return m_index < other.m_index; }
55
56 int64_t index() const noexcept { return m_index; }
57 bool is_valid() const noexcept { return m_index != -1; }
58};
59
60} // namespace attribute
62} // namespace wmtk
Internal handle representation used by TypedAttributeManager.
bool operator<(const AttributeHandle &other) const noexcept
AttributeHandle(AttributeHandle &&)=default
int64_t index() const noexcept
AttributeHandle & operator=(const AttributeHandle &)=default
AttributeHandle(const AttributeHandle &)=default
AttributeHandle & operator=(AttributeHandle &&)=default
AttributeHandle & operator=(int64_t i)
bool operator==(const AttributeHandle &other) const noexcept
Handle that represents attributes for some mesh.
Contains all attributes of type T for a single mesh.
attribute::TypedAttributeHandle< T > TypedAttributeHandle