12 template <
typename T,
int Dim>
33 template <
typename Derived>
34 void try_caching(int64_t index,
const Eigen::MatrixBase<Derived>& value);
72 int D = Eigen::Dynamic,
73 int D2 = Eigen::Dynamic,
74 int TrueD = D == Eigen::Dynamic ? D2 : D>
79 int D = Eigen::Dynamic,
80 int D2 = Eigen::Dynamic,
81 int TrueD = D == Eigen::Dynamic ? D2 : D>
89 template <
int D = Eigen::Dynamic>
92 template <
int D = Eigen::Dynamic>
113 size_t scope_index)
const;
117 size_t scope_index)
const;
139 template <
typename T>
142 -> std::vector<std::pair<size_t, size_t>>::const_iterator
144 return m_indices.begin() + m_transaction_starts[scope_index];
146 template <
typename T>
148 ->
std::vector<
std::pair<
size_t,
size_t>>::const_iterator
151 return m_indices.begin() + m_indices_end;
154 template <
typename T>
156 -> std::vector<std::pair<size_t, size_t>>::const_reverse_iterator
158 return std::reverse_iterator(transaction_start_begin(scope_index));
160 template <
typename T>
162 ->
std::vector<
std::pair<
size_t,
size_t>>::const_reverse_iterator
164 return std::reverse_iterator(final_transaction_end());
167 template <
typename T>
170 return m_transaction_starts.size();
173 template <
typename T>
177 assert(at_current_scope());
178 apply_last_scope(attr);
181 template <
typename T>
182 template <
int D,
int D2,
int TrueD>
187 assert(writing_enabled());
189 static_assert(D == Eigen::Dynamic || D2 == Eigen::Dynamic || D == D2);
190 auto data = accessor.template vector_attribute<TrueD>(index);
191 assert(data.cols() == 1);
192 if constexpr (D != Eigen::Dynamic) {
193 assert(data.size() == D);
195 if constexpr (D2 != Eigen::Dynamic) {
196 assert(data.size() == D2);
201 try_caching(index, data);
207 template <
typename T>
208 template <
int D,
int D2,
int TrueD>
213 static_assert(D == Eigen::Dynamic || D2 == Eigen::Dynamic || D == D2);
214 if (!at_current_scope()) {
215 assert(m_current_transaction_index < m_transaction_starts.size());
218 if (ptr !=
nullptr) {
219 const int dim = accessor.dimension();
224 return accessor.template const_vector_attribute<TrueD>(index);
227 template <
typename T>
233 assert(writing_enabled());
234 T& value = accessor.scalar_attribute(index);
236 try_caching(index, value);
242 template <
typename T>
246 int64_t index)
const -> T
248 return const_vector_attribute<1>(accessor, index)(0);
250 template <
typename T>
255 int8_t offset)
const -> T
257 if (!at_current_scope()) {
258 return const_vector_attribute<D2>(accessor, index)(offset);
260 return accessor.const_scalar_attribute(index, offset);
This class stores data of type T in a vector.
T const_scalar_attribute(const AccessorBase< T, D > &accessor, int64_t index) const
default immutable scalar access
internal::MapResult< T, D > MapResult
size_t indices_end() const
void update_buffer_sizes_for_add(size_t data_size)
void rollback_current_scope(Attribute< T > &attr)
AttributeTransactionStack & operator=(const AttributeTransactionStack &)=delete
std::vector< size_t > m_transaction_starts
void pop(Attribute< T > &attribute, bool preserve_changes)
void change_to_previous_scope()
size_t buffer_end() const
std::vector< T > m_buffer
const std::vector< T > & buffer() const
bool at_current_scope() const
checks that we are viewing the active state of the attribute
std::vector< std::pair< size_t, size_t > >::const_reverse_iterator final_transaction_rbegin() const
MapResult< TrueD > vector_attribute(AccessorBase< T, D2 > &accessor, int64_t index)
default mutable vector access
void change_to_current_scope()
const std::vector< size_t > & transaction_starts() const
AttributeTransactionStack(const AttributeTransactionStack &)=delete
ConstMapResult< TrueD > const_vector_attribute(const AccessorBase< T, D2 > &accessor, int64_t index) const
default immutable vector access
AttributeTransactionStack(AttributeTransactionStack &&)=default
std::vector< std::pair< size_t, size_t > >::const_iterator final_transaction_end() const
size_t m_current_transaction_index
internal::ConstMapResult< T, D > ConstMapResult
size_t current_transaction_index()
void try_caching(int64_t index, const Eigen::MatrixBase< Derived > &value)
bool writing_enabled() const
~AttributeTransactionStack()
std::vector< std::pair< size_t, size_t > >::const_reverse_iterator transaction_start_rend(size_t scope_index) const
size_t current_transaction_index() const
T const_scalar_attribute(const AccessorBase< T, D > &accessor, int64_t index, int8_t offset) const
specialized immutable scalar access useful for topological operations
std::vector< std::pair< size_t, size_t > > m_indices
AttributeTransactionStack & operator=(AttributeTransactionStack &&)=default
std::vector< std::pair< size_t, size_t > >::const_iterator transaction_start_begin(size_t scope_index) const
AttributeTransactionStack()
void apply_to(Attribute< T > &attribute) const
const std::vector< std::pair< size_t, size_t > > & indices() const
void apply_last_scope(Attribute< T > &attr)
T & scalar_attribute(AccessorBase< T, D2 > &accessor, int64_t index)
default mutable scalar access
void change_to_next_scope()
const T * get_value(int64_t index) const
typename VectorResult< T, R >::MapType MapResult
the default map type used by attributes is a map of our vector type.
typename VectorResult< T, R >::ConstMapType ConstMapResult
double get_value(float x)