Geogram Version 1.8.5
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. | |
void | resize (index_t new_size) override |
Resizes this AttributeStore. | |
void | reserve (index_t new_capacity) override |
Reserves memory. | |
void | clear (bool keep_memory=false) override |
Resizes this AttributeStore to 0. | |
void | redim (index_t dim) override |
Sets the dimension. | |
bool | elements_type_matches (const std::string &type_name) const override |
Tests whether this AttributeStore stores elements of a given type. | |
std::string | element_typeid_name () const override |
Gets the typeid name of the element type stored in this AttributeStore. | |
AttributeStore * | clone () const override |
Creates a new AttributeStore that is a carbon copy of this AttributeStore. | |
vector< T > & | get_vector () |
![]() | |
AttributeStore (index_t elemsize, index_t dim=1) | |
AttributeStore constructor. | |
virtual | ~AttributeStore () |
AttributeStore destructor. | |
index_t | size () const |
Gets the size. | |
index_t | capacity () const |
Gets the capacity. | |
bool | has_observers () const |
Tests whether observers listen to this AttributeStore. | |
index_t | dimension () const |
Gets the dimension. | |
virtual void | apply_permutation (const vector< index_t > &permutation) |
Applies a permutation to the stored attributes. | |
virtual void | compress (const vector< index_t > &old2new) |
Compresses the stored attributes, by applying an index mapping that fills-in the gaps. | |
virtual void | zero () |
Zeroes all the memory associated with this AttributeStore. | |
void | copy_item (index_t to, index_t from) |
Copies an item. | |
void | swap_items (index_t i, index_t j) |
Swaps two items. | |
void * | data () |
Gets a pointer to the stored data. | |
const void * | data () const |
Gets a pointer to the stored data. | |
size_t | element_size () const |
Gets the element size. | |
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. | |
![]() | |
void | register_observer (AttributeStoreObserver *observer) |
Registers an observer. | |
void | unregister_observer (AttributeStoreObserver *observer) |
Unregisters an observer. | |
Additional Inherited Members | |
![]() | |
static bool | element_type_name_is_known (const std::string &element_type_name) |
Tests whether a given element type is registered in the system. | |
static bool | element_typeid_name_is_known (const std::string &element_typeid_name) |
Tests whether a given element type is registered in the system. | |
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. | |
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. | |
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. | |
static void | register_attribute_creator (AttributeStoreCreator *creator, const std::string &element_type_name, const std::string &element_typeid_name) |
Registers a new element type. | |
![]() | |
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 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 574 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 583 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 608 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 648 of file attributes.h.
|
inlineoverridevirtual |
Gets the typeid name of the element type stored in this AttributeStore.
Implements GEO::AttributeStore.
Definition at line 644 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 638 of file attributes.h.
|
inline |
Definition at line 656 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 661 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 618 of file attributes.h.
|
inlineoverridevirtual |
Reserves memory.
[in] | new_capacity | total number of items to be stored. |
Implements GEO::AttributeStore.
Definition at line 596 of file attributes.h.
|
inlineoverridevirtual |
Resizes this AttributeStore.
[in] | new_size | new number of items |
Implements GEO::AttributeStore.
Definition at line 587 of file attributes.h.