Geogram Version 1.9.6-rc
A programming library of geometric algorithms
|
Access to an attribute as a double regardless its type. More...
#include <geogram/basic/attributes.h>
Classes | |
class | Accessor |
Accessor class used by ScalarAttributeAdapter to implement indexing operator. More... | |
class | ConstAccessor |
Accessor class used by ScalarAttributeAdapter to implement indexing operator (const version). More... | |
Public Types | |
enum | ElementType { ET_NONE =0 , ET_UINT8 =1 , ET_INT8 =2 , ET_UINT32 =3 , ET_INT32 =4 , ET_FLOAT32 =5 , ET_FLOAT64 =6 , ET_VEC2 =7 , ET_VEC3 =8 } |
Internal representation of the attribute. More... | |
Public Member Functions | |
ScalarAttributeAdapterBase () | |
ScalarAttributeAdapterBase constructor. | |
ScalarAttributeAdapterBase (const AttributesManager &manager, const std::string &name) | |
ScalarAttributeAdapterBase constructor. | |
bool | is_bound () const |
Tests whether an Attribute is bound. | |
void | unbind () |
Unbinds this Attribute. | |
void | bind_if_is_defined (const AttributesManager &manager, const std::string &name) |
Binds this Attribute to an AttributesManager if it already exists in the AttributesManager. | |
~ScalarAttributeAdapterBase () | |
ReadonlyScalarAttributeAdapterBase destructor. | |
index_t | size () const |
Gets the size. | |
ElementType | element_type () const |
Gets the internal representation of the elements. | |
index_t | element_index () const |
Gets the element index. | |
const AttributeStore * | attribute_store () const |
Gets the AttributeStore. | |
![]() | |
AttributeStoreObserver () | |
Creates a new uninitialied AttributeStore. | |
void | notify (Memory::pointer base_addr, index_t size, index_t dim) |
Callback function, called by the AttributeStore whenever it is modified. | |
index_t | size () const |
Gets the size. | |
index_t | dimension () const |
Gets the dimension. | |
index_t | nb_elements () const |
Gets the total number of elements. | |
Memory::pointer | base_addr () const |
Gets a pointer to the storage. | |
void | register_me (AttributeStore *store) |
Registers this observer to an AttributeStore. | |
void | unregister_me (AttributeStore *store) |
Unregisters this observer from an AttributeStore. | |
void | disconnect () |
Disconnects this AttributeStoreObserver from its AttributeStore. | |
bool | disconnected () const |
Tests whether this AttributeStoreObserver was disconnected. | |
Static Public Member Functions | |
static bool | is_defined (const AttributesManager &manager, const std::string &name) |
Tests whether an attribute with the specified name and with a type that can be converted to double exists in an AttributesManager. | |
static bool | can_be_bound_to (const AttributeStore *store) |
Tests whether a ScalarAttributeAdapterBase can be bound to a given attribute store. | |
static index_t | nb_scalar_elements_per_item (const AttributeStore *store) |
Gets the number of scalar components per item in an AttributeStore. | |
Protected Member Functions | |
double | get_element_as_double (index_t i) const |
Gets an attribute value. | |
template<class T > | |
T | get_element (index_t i, index_t multiplier=1) const |
Gets an element. | |
double | set_element_as_double (index_t i, double value) |
Sets an attribute value. | |
template<class T > | |
void | set_element (T value, index_t i, index_t multiplier=1) const |
Sets an element. | |
Static Protected Member Functions | |
static std::string | attribute_base_name (const std::string &name) |
Gets the base attribute name from a compound name. | |
static index_t | attribute_element_index (const std::string &name) |
Gets the base attribute name from a compound name. | |
static ElementType | element_type (const AttributeStore *store) |
Gets the element type stored in an AttributeStore. | |
Protected Attributes | |
const AttributesManager * | manager_ |
const AttributeStore * | store_ |
ElementType | element_type_ |
index_t | element_index_ |
![]() | |
Memory::pointer | base_addr_ |
index_t | size_ |
index_t | dimension_ |
bool | disconnected_ |
Access to an attribute as a double regardless its type.
The attribute can be an element of a vector attribute.
Definition at line 1741 of file attributes.h.
Internal representation of the attribute.
Definition at line 1748 of file attributes.h.
|
inline |
ScalarAttributeAdapterBase constructor.
Definition at line 1810 of file attributes.h.
|
inline |
ScalarAttributeAdapterBase constructor.
Retrieves a persistent attribute attached to a given AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
Definition at line 1826 of file attributes.h.
|
inline |
ReadonlyScalarAttributeAdapterBase destructor.
The attribute is not destroyed, it can be retrieved later by binding with the same name. To destroy the attribute, use destroy() instead.
Definition at line 1876 of file attributes.h.
|
staticprotected |
Gets the base attribute name from a compound name.
[in] | name | the string with the attribute name and optional index. For instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
staticprotected |
Gets the base attribute name from a compound name.
[in] | name | the string with the attribute name and optional index. For instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
inline |
Gets the AttributeStore.
Definition at line 1928 of file attributes.h.
void GEO::ScalarAttributeAdapterBase::bind_if_is_defined | ( | const AttributesManager & | manager, |
const std::string & | name | ||
) |
Binds this Attribute to an AttributesManager if it already exists in the AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
inlinestatic |
Tests whether a ScalarAttributeAdapterBase can be bound to a given attribute store.
[in] | store | a pointer to the attribute store. |
true | if it can be bound |
false | otherwise |
Definition at line 1940 of file attributes.h.
|
inline |
Gets the element index.
Definition at line 1920 of file attributes.h.
|
inline |
Gets the internal representation of the elements.
Definition at line 1910 of file attributes.h.
|
staticprotected |
Gets the element type stored in an AttributeStore.
[in] | store | a const pointer to the AttributeStore |
|
inlineprotected |
Gets an element.
Stored element type needs to match T, no verification is made
[in] | i | index of the element |
[in] | multiplier | multiplier applied to the index before fetching the raw pointer. |
Definition at line 2031 of file attributes.h.
|
inlineprotected |
Gets an attribute value.
[in] | i | the index of the item |
Definition at line 1990 of file attributes.h.
|
inline |
Tests whether an Attribute is bound.
true | if this Attribute is bound |
false | otherwise |
Definition at line 1839 of file attributes.h.
|
static |
Tests whether an attribute with the specified name and with a type that can be converted to double exists in an AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | the name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
static |
Gets the number of scalar components per item in an AttributeStore.
[in] | store | a pointer to the attribute store. |
|
inlineprotected |
Sets an element.
Stored element type needs to match T, no verification is made
[in] | value | the value of the element to be stored |
[in] | i | index of the element |
[in] | multiplier | multiplier applied to the index before fetching the raw pointer. |
Definition at line 2088 of file attributes.h.
|
inlineprotected |
Sets an attribute value.
[in] | i | the index of the element |
[in] | value | the new value of the element |
Definition at line 2046 of file attributes.h.
|
inline |
Gets the size.
Definition at line 1899 of file attributes.h.
|
inline |
|
protected |
Definition at line 2103 of file attributes.h.
|
protected |
Definition at line 2102 of file attributes.h.
|
protected |
Definition at line 2100 of file attributes.h.
|
protected |
Definition at line 2101 of file attributes.h.