Notifies a set of AttributeStoreObservers each time the stored array changes size and/or base address and/or dimension.
More...
#include <geogram/basic/attributes.h>
|
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_ |
|
|
class | AttributeStoreObserver |
|
Notifies a set of AttributeStoreObservers each time the stored array changes size and/or base address and/or dimension.
Definition at line 195 of file attributes.h.
◆ AttributeStore()
GEO::AttributeStore::AttributeStore |
( |
index_t |
elemsize, |
|
|
index_t |
dim = 1 |
|
) |
| |
AttributeStore constructor.
- Parameters
-
[in] | elemsize | size of one element, in bytes. |
[in] | dim | number of elements in each item. Default is 1 for standard attributes and can be greater for vector attributes. |
◆ apply_permutation()
virtual void GEO::AttributeStore::apply_permutation |
( |
const vector< index_t > & |
permutation | ) |
|
|
virtual |
Applies a permutation to the stored attributes.
Applying a permutation to the data is equivalent to:
for(i=0; i<permutation.size(); i++) {
data2[i] =
data[permutation[i]]
}
void * data()
Gets a pointer to the stored data.
But it is done in-place.
- Parameters
-
[in] | permutation | the permutation. It is temporarily changed during execution of the function, but identical to the input on exit. |
- Note
- This function uses memcpy(). If required, it can be overloaded in derived classes.
◆ capacity()
index_t GEO::AttributeStore::capacity |
( |
| ) |
const |
|
inline |
Gets the capacity.
- Returns
- the number of items that can be stored without a reallocation.
Definition at line 247 of file attributes.h.
◆ clear()
virtual void GEO::AttributeStore::clear |
( |
bool |
keep_memory = false | ) |
|
|
pure virtual |
◆ clone()
◆ compress()
virtual void GEO::AttributeStore::compress |
( |
const vector< index_t > & |
old2new | ) |
|
|
virtual |
Compresses the stored attributes, by applying an index mapping that fills-in the gaps.
This is equivalent to:
for(i=0; i<
size(); i++) {
data2[old2new[i]] =
data[i];
}
}
index_t size() const
Gets the size.
geo_index_t index_t
The type for storing and manipulating indices.
- Parameters
-
[in] | old2new | the index mapping to be applied. |
- Precondition
- old2new[i] <= i || old2new[i] == index_t(-1)
- Note
- This function uses memcpy(). If required, it can be overloaded in derived classes.
◆ copy_item()
Copies an item.
- Parameters
-
[in] | to | index of the destination item |
[in] | from | index of the source item |
Definition at line 363 of file attributes.h.
◆ create_attribute_store_by_element_type_name()
static AttributeStore* GEO::AttributeStore::create_attribute_store_by_element_type_name |
( |
const std::string & |
element_type_name, |
|
|
index_t |
dimension |
|
) |
| |
|
inlinestatic |
Creates an attribute store of a given type.
- Parameters
-
[in] | element_type_name | a const reference to a string with the C++ type of the elements to be stored in the attribute |
[in] | dimension | number of elements in each item |
Definition at line 476 of file attributes.h.
◆ data() [1/2]
void* GEO::AttributeStore::data |
( |
| ) |
|
|
inline |
Gets a pointer to the stored data.
- Returns
- A pointer to the memory block
Definition at line 416 of file attributes.h.
◆ data() [2/2]
const void* GEO::AttributeStore::data |
( |
| ) |
const |
|
inline |
Gets a pointer to the stored data.
- Returns
- A const pointer to the memory block
Definition at line 424 of file attributes.h.
◆ dimension()
index_t GEO::AttributeStore::dimension |
( |
| ) |
const |
|
inline |
Gets the dimension.
The dimension is 1 for standard attributes and can be greater for vector attributes.
Definition at line 285 of file attributes.h.
◆ element_size()
size_t GEO::AttributeStore::element_size |
( |
| ) |
const |
|
inline |
Gets the element size.
- Returns
- the size of an element, in bytes
Definition at line 432 of file attributes.h.
◆ element_type_name_by_element_typeid_name()
static std::string GEO::AttributeStore::element_type_name_by_element_typeid_name |
( |
const std::string & |
element_typeid_name | ) |
|
|
inlinestatic |
Gets an element type name from its mangled name.
- Parameters
-
[in] | element_typeid_name | a const reference to a string with the mangled type name, as given by typeid(T).name() |
- Returns
- a string with the C++ type name
- Precondition
- element_typeid_name_is_known(element_typeid_name)
Definition at line 492 of file attributes.h.
◆ element_type_name_is_known()
static bool GEO::AttributeStore::element_type_name_is_known |
( |
const std::string & |
element_type_name | ) |
|
|
inlinestatic |
Tests whether a given element type is registered in the system.
- Parameters
-
[in] | element_type_name | a const reference to a string with the C++ type name |
- Return values
-
true | if the element type was registered |
false | otherwise |
Definition at line 444 of file attributes.h.
◆ element_typeid_name()
virtual std::string GEO::AttributeStore::element_typeid_name |
( |
| ) |
const |
|
pure virtual |
◆ element_typeid_name_by_element_type_name()
static std::string GEO::AttributeStore::element_typeid_name_by_element_type_name |
( |
const std::string & |
element_type_name | ) |
|
|
inlinestatic |
Gets an element mangled type name from its C++ name.
- Parameters
-
[in] | element_type_name | a reference to a string with the C++ type name |
- Returns
- a string with the mangled type name, as given by typeid(T).name()
- Precondition
- element_type_name_is_known(element_type_name)
Definition at line 507 of file attributes.h.
◆ element_typeid_name_is_known()
static bool GEO::AttributeStore::element_typeid_name_is_known |
( |
const std::string & |
element_typeid_name | ) |
|
|
inlinestatic |
Tests whether a given element type is registered in the system.
- Parameters
-
[in] | element_typeid_name | a const reference to a string with the mangled type, as given by typeid(T).name() |
- Return values
-
true | if the element type was registered |
false | otherwise |
Definition at line 461 of file attributes.h.
◆ elements_type_matches()
virtual bool GEO::AttributeStore::elements_type_matches |
( |
const std::string & |
type_name | ) |
const |
|
pure virtual |
◆ has_observers()
bool GEO::AttributeStore::has_observers |
( |
| ) |
const |
|
inline |
◆ madd_item()
virtual void GEO::AttributeStore::madd_item |
( |
index_t |
to, |
|
|
double |
s, |
|
|
index_t |
from |
|
) |
| |
|
virtual |
Adds a scaled item to another item \detais item[to] += s * item[from].
- Parameters
-
[in] | to | the item |
[in] | s | the scaling factor |
[in] | from | the item to be scaled and added |
default implementation does nothing
Reimplemented in GEO::TypedAttributeStore< T >.
◆ notify()
If size or base address differ from the cached values, notify all the observers, and update the cached base address and size.
- Parameters
-
[in] | base_addr | the new base address |
[in] | size | the new size |
[in] | dim | the new dimension |
Reimplemented in GEO::TypedAttributeStore< T >.
◆ redim()
virtual void GEO::AttributeStore::redim |
( |
index_t |
dim | ) |
|
|
pure virtual |
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.
- Parameters
-
Implemented in GEO::TypedAttributeStore< T >.
◆ register_attribute_creator()
static void GEO::AttributeStore::register_attribute_creator |
( |
AttributeStoreCreator * |
creator, |
|
|
const std::string & |
element_type_name, |
|
|
const std::string & |
element_typeid_name |
|
) |
| |
|
inlinestatic |
Registers a new element type.
- Note
- Internal use function, one should use geo_register_attribute_type instead
- Parameters
-
[in] | creator | a pointer to the AttributeStoreCreator |
[in] | element_type_name | a const reference to a string with the C++ type name of the elements |
[in] | element_typeid_name | a const reference to a string with the mangled type name of the elements, as given by typeid(T).name() |
Definition at line 524 of file attributes.h.
◆ register_observer()
Registers an observer.
All the registered observers are notified whenever the size or base pointer in this AttributeStore change. The function is thread-safe.
- Parameters
-
◆ reserve()
virtual void GEO::AttributeStore::reserve |
( |
index_t |
new_capacity | ) |
|
|
pure virtual |
◆ resize()
virtual void GEO::AttributeStore::resize |
( |
index_t |
new_size | ) |
|
|
pure virtual |
◆ scale_item()
virtual void GEO::AttributeStore::scale_item |
( |
index_t |
to, |
|
|
double |
s |
|
) |
| |
|
virtual |
Scales an item.
item[to] *= s
- Parameters
-
[in] | to | the index of the item |
[in] | s | the scaling factor |
default implementation does nothing
Reimplemented in GEO::TypedAttributeStore< T >.
◆ size()
index_t GEO::AttributeStore::size |
( |
| ) |
const |
|
inline |
Gets the size.
- Returns
- the number of items
Definition at line 238 of file attributes.h.
◆ swap_items()
Swaps two items.
- Parameters
-
[in] | i,j | the indices of the items to be swapped |
◆ unregister_observer()
Unregisters an observer.
- Parameters
-
- Precondition
observer
is registered.
◆ zero()
virtual void GEO::AttributeStore::zero |
( |
| ) |
|
|
virtual |
Zeroes all the memory associated with this AttributeStore.
Subclasses may overload this function for attributes that have non "plain ordinary datatypes" and that need a more elaborate initialization mechanism.
◆ zero_item()
void GEO::AttributeStore::zero_item |
( |
index_t |
to | ) |
|
|
inline |
Sets an item to zero.
- Parameters
-
Definition at line 378 of file attributes.h.
The documentation for this class was generated from the following file: