Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Stores an array of elements of a given type, and notifies a set of AttributeStoreObservers each time the storead array changes size and/or base address. More...
#include <geogram/basic/attributes.h>
Public Member Functions | |
TypedAttributeStore (index_t dim=1) | |
Creates a new empty attribute store. More... | |
void | resize (index_t new_size) override |
Resizes this AttributeStore. More... | |
void | reserve (index_t new_capacity) override |
Reserves memory. More... | |
void | clear (bool keep_memory=false) override |
Resizes this AttributeStore to 0. More... | |
void | redim (index_t dim) override |
Sets the dimension. More... | |
bool | elements_type_matches (const std::string &type_name) const override |
Tests whether this AttributeStore stores elements of a given type. More... | |
std::string | element_typeid_name () const override |
Gets the typeid name of the element type stored in this AttributeStore. More... | |
AttributeStore * | clone () const override |
Creates a new AttributeStore that is a carbon copy of this AttributeStore. More... | |
vector< T > & | get_vector () |
void | scale_item (index_t to, double s) override |
Scales an item. More... | |
void | madd_item (index_t to, double s, index_t from) override |
Adds a scaled item to another item \detais item[to] += s * item[from]. More... | |
Public Member Functions inherited from GEO::AttributeStore | |
AttributeStore (index_t elemsize, index_t dim=1) | |
AttributeStore constructor. More... | |
virtual | ~AttributeStore () |
AttributeStore destructor. | |
index_t | size () const |
Gets the size. More... | |
index_t | capacity () const |
Gets the capacity. More... | |
bool | has_observers () const |
Tests whether observers listen to this AttributeStore. More... | |
index_t | dimension () const |
Gets the dimension. More... | |
virtual void | apply_permutation (const vector< index_t > &permutation) |
Applies a permutation to the stored attributes. More... | |
virtual void | compress (const vector< index_t > &old2new) |
Compresses the stored attributes, by applying an index mapping that fills-in the gaps. More... | |
virtual void | zero () |
Zeroes all the memory associated with this AttributeStore. More... | |
void | copy_item (index_t to, index_t from) |
Copies an item. More... | |
void | zero_item (index_t to) |
Sets an item to zero. More... | |
void | swap_items (index_t i, index_t j) |
Swaps two items. More... | |
void * | data () |
Gets a pointer to the stored data. More... | |
const void * | data () const |
Gets a pointer to the stored data. More... | |
size_t | element_size () const |
Gets the element size. More... | |
Protected Member Functions | |
void | notify (Memory::pointer base_addr, index_t size, index_t dim) override |
If size or base address differ from the cached values, notify all the observers, and update the cached base address and size. More... | |
Protected Member Functions inherited from GEO::AttributeStore | |
void | register_observer (AttributeStoreObserver *observer) |
Registers an observer. More... | |
void | unregister_observer (AttributeStoreObserver *observer) |
Unregisters an observer. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from GEO::AttributeStore | |
static bool | element_type_name_is_known (const std::string &element_type_name) |
Tests whether a given element type is registered in the system. More... | |
static bool | element_typeid_name_is_known (const std::string &element_typeid_name) |
Tests whether a given element type is registered in the system. More... | |
static AttributeStore * | create_attribute_store_by_element_type_name (const std::string &element_type_name, index_t dimension) |
Creates an attribute store of a given type. More... | |
static std::string | element_type_name_by_element_typeid_name (const std::string &element_typeid_name) |
Gets an element type name from its mangled name. More... | |
static std::string | element_typeid_name_by_element_type_name (const std::string &element_type_name) |
Gets an element mangled type name from its C++ name. More... | |
static void | register_attribute_creator (AttributeStoreCreator *creator, const std::string &element_type_name, const std::string &element_typeid_name) |
Registers a new element type. More... | |
Protected Attributes inherited from GEO::AttributeStore | |
index_t | element_size_ |
index_t | dimension_ |
Memory::pointer | cached_base_addr_ |
index_t | cached_size_ |
index_t | cached_capacity_ |
std::set< AttributeStoreObserver * > | observers_ |
Process::spinlock | lock_ |
Static Protected Attributes inherited from GEO::AttributeStore | |
static std::map< std::string, AttributeStoreCreator_var > | type_name_to_creator_ |
static std::map< std::string, std::string > | typeid_name_to_type_name_ |
static std::map< std::string, std::string > | type_name_to_typeid_name_ |
Stores an array of elements of a given type, and notifies a set of AttributeStoreObservers each time the storead array changes size and/or base address.
Definition at line 607 of file attributes.h.
|
inline |
Creates a new empty attribute store.
[in] | dim | number of elements in each item, default value is 1, can be greater for vector attributes. |
Definition at line 616 of file attributes.h.
|
inlineoverridevirtual |
Resizes this AttributeStore to 0.
[in] | keep_memory | if true, then memory is kept reserved for future use. |
Implements GEO::AttributeStore.
Definition at line 641 of file attributes.h.
|
inlineoverridevirtual |
Creates a new AttributeStore that is a carbon copy of this AttributeStore.
Only the data is copied, observers are not copied.
Implements GEO::AttributeStore.
Definition at line 681 of file attributes.h.
|
inlineoverridevirtual |
Gets the typeid name of the element type stored in this AttributeStore.
Implements GEO::AttributeStore.
Definition at line 677 of file attributes.h.
|
inlineoverridevirtual |
Tests whether this AttributeStore stores elements of a given type.
[in] | type_name | the name of the type, as given by typeid(T).name() |
true | if this AttributeStore stores elements of type type_name |
false | otherwise |
Implements GEO::AttributeStore.
Definition at line 671 of file attributes.h.
|
inlineoverridevirtual |
Adds a scaled item to another item \detais item[to] += s * item[from].
[in] | to | the item |
[in] | s | the scaling factor |
[in] | from | the item to be scaled and added |
default implementation does nothing
Reimplemented from GEO::AttributeStore.
Definition at line 700 of file attributes.h.
|
inlineoverrideprotectedvirtual |
If size or base address differ from the cached values, notify all the observers, and update the cached base address and size.
[in] | base_addr | the new base address |
[in] | size | the new size |
[in] | dim | the new dimension |
Reimplemented from GEO::AttributeStore.
Definition at line 711 of file attributes.h.
|
inlineoverridevirtual |
Sets the dimension.
The dimension is 1 for standard attributes and can be greater for vector attributes. The existing fields are kept. If the new dimension is greater than the old one, then new fields are initialized to the default value for the attribute type.
[in] | dim | the new dimension |
Implements GEO::AttributeStore.
Definition at line 651 of file attributes.h.
|
inlineoverridevirtual |
Reserves memory.
[in] | new_capacity | total number of items to be stored. |
Implements GEO::AttributeStore.
Definition at line 629 of file attributes.h.
|
inlineoverridevirtual |
Resizes this AttributeStore.
[in] | new_size | new number of items |
Implements GEO::AttributeStore.
Definition at line 620 of file attributes.h.
|
inlineoverridevirtual |
Scales an item.
item[to] *= s
[in] | to | the index of the item |
[in] | s | the scaling factor |
default implementation does nothing
Reimplemented from GEO::AttributeStore.
Definition at line 693 of file attributes.h.