Geogram Version 1.9.6-rc
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GEO::Attribute< T > Class Template Reference

Manages an attribute attached to a set of object. More...

#include <geogram/basic/attributes.h>

Inheritance diagram for GEO::Attribute< T >:
GEO::AttributeBase< T > GEO::AttributeStoreObserver

Public Types

typedef AttributeBase< T > superclass
 

Public Member Functions

 Attribute ()
 Creates an uninitialized (unbound) Attribute.
 
 Attribute (AttributesManager &manager, const std::string &name)
 Creates or retrieves a persistent attribute attached to a given AttributesManager.
 
T & operator[] (index_t i)
 Gets a modifiable element by index.
 
const T & operator[] (index_t i) const
 Gets an element by index.
 
void fill (const T &val)
 Sets all the elements in this attribute to a specified value.
 
void copy (const Attribute< T > &rhs)
 Copies all the values from another attribute.
 
T * data ()
 Gets the pointer to the data.
 
const T * data () const
 Gets the pointer to the data.
 
- Public Member Functions inherited from GEO::AttributeBase< T >
 AttributeBase ()
 Creates an uninitialized (unbound) Attribute.
 
 AttributeBase (AttributesManager &manager, const std::string &name)
 Creates or retrieves a persistent attribute attached to a given AttributesManager.
 
bool is_bound () const
 Tests whether an Attribute is bound.
 
void unbind ()
 Unbinds this Attribute.
 
void bind (AttributesManager &manager, const std::string &name)
 Binds this Attribute to an AttributesManager.
 
bool bind_if_is_defined (AttributesManager &manager, const std::string &name)
 Binds this Attribute to an AttributesManager if it already exists in the AttributesManager.
 
bool bind_if_is_compatible (AttributesManager &manager, const std::string &name)
 Binds this Attribute to an AttributesManager if it already exists in the AttributesManager and types are compatible.
 
void create_vector_attribute (AttributesManager &manager, const std::string &name, index_t dimension)
 Creates and binds a new vector attribute.
 
void destroy ()
 Destroys this attribute in the AttributesManager.
 
void redim (index_t new_dim)
 Sets the dimension.
 
 ~AttributeBase ()
 Attribute destructor.
 
index_t size () const
 Gets the size.
 
void zero ()
 Sets all the elements of this Attribute to zero.
 
bool can_get_vector ()
 Tests whether get_vector() can be called on this Attribute.
 
vector< T > & get_vector ()
 Gets a reference to the internal vector<T> used to store the attribute.
 
const vector< T > & get_vector () const
 Gets a const reference to the internal vector<T> used to store the attribute.
 
AttributesManagermanager () const
 Gets the AttributesManager this Attribute is bound to.
 
- Public Member Functions inherited from GEO::AttributeStoreObserver
 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 void static_test_type ()
 Tests at compile time whether type can be used in an Attribute. If not the case generates a compile-time error.
 
- Static Public Member Functions inherited from GEO::AttributeBase< T >
static bool is_defined (AttributesManager &manager, const std::string &name, index_t dim=0)
 Tests whether an attribute with the specified name and with corresponding type exists in an AttributesManager.
 

Additional Inherited Members

- Protected Attributes inherited from GEO::AttributeBase< T >
AttributesManagermanager_
 
AttributeStorestore_
 
- Protected Attributes inherited from GEO::AttributeStoreObserver
Memory::pointer base_addr_
 
index_t size_
 
index_t dimension_
 
bool disconnected_
 

Detailed Description

template<class T>
class GEO::Attribute< T >

Manages an attribute attached to a set of object.

Template Parameters
Ttype of the attributes. Needs to be a basic type or a plain ordinary datatype (classes that do dynamic memory allocation are not allowed here).

Definition at line 1409 of file attributes.h.

Member Typedef Documentation

◆ superclass

template<class T >
typedef AttributeBase<T> GEO::Attribute< T >::superclass

Definition at line 1411 of file attributes.h.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

template<class T >
GEO::Attribute< T >::Attribute ( )
inline

Creates an uninitialized (unbound) Attribute.

Definition at line 1438 of file attributes.h.

◆ Attribute() [2/2]

template<class T >
GEO::Attribute< T >::Attribute ( AttributesManager manager,
const std::string &  name 
)
inline

Creates or retrieves a persistent attribute attached to a given AttributesManager.

If the attribute already exists with the specified name in the AttributesManager then it is retrieved, else it is created and bound to the name.

Parameters
[in]managera reference to the AttributesManager
[in]namename of the attribute

Definition at line 1451 of file attributes.h.

Member Function Documentation

◆ copy()

template<class T >
void GEO::Attribute< T >::copy ( const Attribute< T > &  rhs)
inline

Copies all the values from another attribute.

Parameters
[in]rhsthe attribute to be copied.

rhs needs to have the same size and dimension as this Attribute.

Definition at line 1496 of file attributes.h.

◆ data() [1/2]

template<class T >
T * GEO::Attribute< T >::data ( )
inline

Gets the pointer to the data.

Returns
a pointer to the stored array.

Definition at line 1508 of file attributes.h.

◆ data() [2/2]

template<class T >
const T * GEO::Attribute< T >::data ( ) const
inline

Gets the pointer to the data.

Returns
a const pointer to the stored array.

Definition at line 1516 of file attributes.h.

◆ fill()

template<class T >
void GEO::Attribute< T >::fill ( const T &  val)
inline

Sets all the elements in this attribute to a specified value.

Parameters
[in]valthe value

Definition at line 1483 of file attributes.h.

◆ operator[]() [1/2]

template<class T >
T & GEO::Attribute< T >::operator[] ( index_t  i)
inline

Gets a modifiable element by index.

Parameters
[in]iindex of the element
Returns
a modifiable reference to the ith element

Definition at line 1461 of file attributes.h.

◆ operator[]() [2/2]

template<class T >
const T & GEO::Attribute< T >::operator[] ( index_t  i) const
inline

Gets an element by index.

Parameters
[in]iindex of the element
Returns
a const reference to the ith element

Definition at line 1472 of file attributes.h.

◆ static_test_type()

template<class T >
static void GEO::Attribute< T >::static_test_type ( )
inlinestatic

Tests at compile time whether type can be used in an Attribute. If not the case generates a compile-time error.

Definition at line 1418 of file attributes.h.


The documentation for this class was generated from the following file: