Geogram Version 1.9.6-rc
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 () |
void | scale_item (index_t to, double s) override |
Scales an item. | |
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]. | |
![]() | |
AttributeStore (size_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 | zero_item (index_t to) |
Sets an item to zero. | |
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. | |
Static Protected Member Functions | |
template<class TT > | |
static void | scale_value (TT &to, double s) |
static void | scale_value (uint8_t &to, double s) |
static void | scale_value (int32_t &to, double s) |
static void | scale_value (uint32_t &to, double s) |
static void | scale_value (float &to, double s) |
static void | scale_value (double &to, double s) |
template<class TT > | |
static void | madd_value (TT &to, double s, TT &from) |
static void | madd_value (uint8_t &to, double s, uint8_t &from) |
static void | madd_value (int32_t &to, double s, int32_t &from) |
static void | madd_value (uint32_t &to, double s, uint32_t &from) |
static void | madd_value (float &to, double s, float &from) |
static void | madd_value (double &to, double s, double &from) |
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. | |
![]() | |
size_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 624 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 633 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 658 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 696 of file attributes.h.
|
inlineoverridevirtual |
Gets the typeid name of the element type stored in this AttributeStore.
Implements GEO::AttributeStore.
Definition at line 692 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 688 of file attributes.h.
|
inline |
Definition at line 704 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 715 of file attributes.h.
|
inlinestaticprotected |
Definition at line 780 of file attributes.h.
|
inlinestaticprotected |
Definition at line 776 of file attributes.h.
|
inlinestaticprotected |
Definition at line 768 of file attributes.h.
|
inlinestaticprotected |
Definition at line 758 of file attributes.h.
|
inlinestaticprotected |
Definition at line 772 of file attributes.h.
|
inlinestaticprotected |
Definition at line 764 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 726 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 668 of file attributes.h.
|
inlineoverridevirtual |
Reserves memory.
[in] | new_capacity | total number of items to be stored. |
Implements GEO::AttributeStore.
Definition at line 646 of file attributes.h.
|
inlineoverridevirtual |
Resizes this AttributeStore.
[in] | new_size | new number of items |
Implements GEO::AttributeStore.
Definition at line 637 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 708 of file attributes.h.
|
inlinestaticprotected |
Definition at line 754 of file attributes.h.
|
inlinestaticprotected |
Definition at line 750 of file attributes.h.
|
inlinestaticprotected |
Definition at line 742 of file attributes.h.
|
inlinestaticprotected |
Definition at line 733 of file attributes.h.
|
inlinestaticprotected |
Definition at line 746 of file attributes.h.
|
inlinestaticprotected |
Definition at line 738 of file attributes.h.