|
Geogram Version 1.10.0-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, const std::type_info &user_type_info=typeid(ST)) | |
| 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. | |
| std::string | user_element_typeid_name () const override |
| Gets the user 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< ST > & | 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]. | |
Public Member Functions inherited from GEO::AttributeStore | |
| 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. | |
| LifeCycle * | lifecycle () const |
| Gets the LifeCycle. | |
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. | |
Protected Member Functions inherited from GEO::AttributeStore | |
| void | apply_permutation_with_lifecycle (const vector< index_t > &permutation) |
| implementation of apply_permutation() used when there is a lifecycle, that is, when attribute type is not trivially copyable. | |
| 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 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. | |
| 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 bool | element_by_type_name_is_trivially_copyable (const std::string &element_type_name) |
| Tests whether an element type is trivially copyable. | |
| static bool | element_by_typeid_name_is_trivially_copyable (const std::string &element_typeid_name) |
| Tests whether an element type is trivially copyable. | |
| 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. | |
Protected Attributes inherited from GEO::AttributeStore | |
| size_t | element_size_ |
| index_t | dimension_ |
| Memory::pointer | cached_base_addr_ |
| index_t | cached_size_ |
| index_t | cached_capacity_ |
| LifeCycle_var | lifecycle_ |
| 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.
| ST | storage type for the elements |
Definition at line 692 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. |
| [in] | user_type_info | optional user type (default is typeid(ST) |
user_type_info is used for instance by Attribute<bool>, with bool as user type and Numeric::uint8 as storage type
Definition at line 704 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 736 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 780 of file attributes.h.
|
inlineoverridevirtual |
Gets the typeid name of the element type stored in this AttributeStore.
Implements GEO::AttributeStore.
Definition at line 772 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 765 of file attributes.h.
|
inline |
Definition at line 789 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 800 of file attributes.h.
|
inlinestaticprotected |
Definition at line 865 of file attributes.h.
|
inlinestaticprotected |
Definition at line 861 of file attributes.h.
|
inlinestaticprotected |
Definition at line 853 of file attributes.h.
|
inlinestaticprotected |
Definition at line 843 of file attributes.h.
|
inlinestaticprotected |
Definition at line 857 of file attributes.h.
|
inlinestaticprotected |
Definition at line 849 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 811 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 745 of file attributes.h.
|
inlineoverridevirtual |
Reserves memory.
| [in] | new_capacity | total number of items to be stored. |
Implements GEO::AttributeStore.
Definition at line 724 of file attributes.h.
|
inlineoverridevirtual |
Resizes this AttributeStore.
| [in] | new_size | new number of items |
Implements GEO::AttributeStore.
Definition at line 715 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 793 of file attributes.h.
|
inlinestaticprotected |
Definition at line 839 of file attributes.h.
|
inlinestaticprotected |
Definition at line 835 of file attributes.h.
|
inlinestaticprotected |
Definition at line 827 of file attributes.h.
|
inlinestaticprotected |
Definition at line 818 of file attributes.h.
|
inlinestaticprotected |
Definition at line 831 of file attributes.h.
|
inlinestaticprotected |
Definition at line 823 of file attributes.h.
|
inlineoverridevirtual |
Gets the user typeid name of the element type stored in this AttributeStore.
May be different from element_typeid_name() for instance for Attribute<bool>, implemented using Numeric::uint8.
Implements GEO::AttributeStore.
Definition at line 776 of file attributes.h.