41#ifndef GEOGRAM_BASIC_VECTOR_ATTRIBUTE
42#define GEOGRAM_BASIC_VECTOR_ATTRIBUTE
54 template <index_t DIM>
class Attribute<
vecng<DIM,double> > {
57 static constexpr index_t vec_dim = DIM;
80 if(store ==
nullptr) {
95 store_ = manager.find_attribute_store(name);
96 if(store_ ==
nullptr) {
98 manager_->bind_attribute_store(name,store_);
101 store_observer_.register_me(store_);
109 if(!store_observer_.disconnected()) {
110 store_observer_.unregister_me(store_);
128 return (store_ !=
nullptr && !store_observer_.disconnected());
132 return store_observer_.size();
155 store_observer_.unregister_me(store_);
156 manager_->delete_attribute_store(store_);
175 store_ = manager.find_attribute_store(name);
176 if(store_ !=
nullptr) {
177 if( !store_->elements_type_matches(
typeid(vec_type).name()) ) {
182 store_observer_.register_me(store_);
194 void copy(
const Attribute<vec_type>& rhs) {
208 void fill(
const vec_type& val) {
215#ifdef GEO_COMPILER_CLANG
216#pragma clang diagnostic push
217#pragma clang diagnostic ignored "-Wcast-align"
221 return ((vec_type*)store_observer_.base_addr())[i];
226 return ((vec_type*)store_observer_.base_addr())[i];
229#ifdef GEO_COMPILER_CLANG
230#pragma clang diagnostic pop
235 AttributesManager* manager_;
236 AttributeStore* store_;
#define geo_assert(x)
Verifies that a condition is met.
#define geo_debug_assert(x)
Verifies that a condition is met.
Generic mechanism for attributes.
void bind(AttributesManager &manager, const std::string &name)
AttributesManager * manager() const
static bool is_defined(AttributesManager &manager, const std::string &name, index_t dim=0)
bool bind_if_is_defined(AttributesManager &manager, const std::string &name)
AttributeStoreObserver()
Creates a new uninitialied AttributeStore.
index_t nb_elements() const
Gets the total number of elements.
index_t dimension() const
Gets the dimension.
Notifies a set of AttributeStoreObservers each time the stored array changes size and/or base address...
index_t dimension() const
Gets the dimension.
virtual bool elements_type_matches(const std::string &type_name) const =0
Tests whether this AttributeStore stores elements of a given type.
bool bind_if_is_compatible(AttributesManager &manager, const std::string &name)
Binds this Attribute to an AttributesManager if it already exists in the AttributesManager and types ...
void destroy()
Destroys this attribute in the AttributesManager.
void fill(const vec_type &val)
Sets all the elements in this attribute to a specified value.
void copy(const Attribute< vec_type > &rhs)
Copies all the values from another attribute.
Attribute()
Creates an uninitialized (unbound) Attribute.
T & operator[](index_t i)
Gets a modifiable element by index.
Manages a set of attributes attached to an object.
Stores an array of elements of a given type, and notifies a set of AttributeStoreObservers each time ...
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.