Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::AttributeBase< T > Class Template Reference

Base class for Attributes, that manipulates an attribute stored in an AttributesManager. More...

#include <geogram/basic/attributes.h>

Inheritance diagram for GEO::AttributeBase< T >:
GEO::AttributeStoreObserver GEO::Attribute< double > GEO::Attribute< GEO::Matrix > GEO::Attribute< float > GEO::Attribute< int > GEO::Attribute< const GEO::vec3Hg * > GEO::Attribute< index_t > GEO::Attribute< GEOGen::SymbolicVertex > GEO::Attribute< GEO::vecng > GEO::Attribute< T >

Public Member Functions

 AttributeBase ()
 Creates an uninitialized (unbound) Attribute.
 
 AttributeBase (AttributesManager &manager, const std::string &name)
 Creates or retrieves a persistent attribute attached to a given AttributesManager. More...
 
bool is_bound () const
 Tests whether an Attribute is bound. More...
 
void unbind ()
 Unbinds this Attribute. More...
 
void bind (AttributesManager &manager, const std::string &name)
 Binds this Attribute to an AttributesManager. More...
 
bool bind_if_is_defined (AttributesManager &manager, const std::string &name)
 Binds this Attribute to an AttributesManager if it already exists in the AttributesManager. More...
 
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 tyopes are compatible. More...
 
void create_vector_attribute (AttributesManager &manager, const std::string &name, index_t dimension)
 Creates and binds a new vector attribute. More...
 
void destroy ()
 Destroys this attribute in the AttributesManager. More...
 
void redim (index_t new_dim)
 Sets the dimension. More...
 
 ~AttributeBase ()
 Attribute destructor. More...
 
index_t size () const
 Gets the size. More...
 
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. More...
 
vector< T > & get_vector ()
 Gets a reference to the internal vector<T> used to store the attribute. More...
 
const vector< T > & get_vector () const
 Gets a const reference to the internal vector<T> used to store the attribute. More...
 
AttributesManagermanager () const
 Gets the AttributesManager this Attribute is bound to. More...
 
- 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. More...
 
index_t size () const
 Gets the size. More...
 
index_t dimension () const
 Gets the dimension. More...
 
index_t nb_elements () const
 Gets the total number of elements. More...
 
void register_me (AttributeStore *store)
 Registers this observer to an AttributeStore. More...
 
void unregister_me (AttributeStore *store)
 Unregisters this observer from an AttributeStore. More...
 
void disconnect ()
 Disconnects this AttributeStoreObserver from its AttributeStore. More...
 

Static Public Member Functions

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. More...
 

Protected Attributes

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::AttributeBase< T >

Base class for Attributes, that manipulates an attribute stored in an AttributesManager.

Definition at line 1108 of file attributes.h.

Constructor & Destructor Documentation

◆ AttributeBase()

template<class T >
GEO::AttributeBase< T >::AttributeBase ( 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 1128 of file attributes.h.

◆ ~AttributeBase()

template<class T >
GEO::AttributeBase< T >::~AttributeBase ( )
inline

Attribute 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 1285 of file attributes.h.

Member Function Documentation

◆ bind()

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

Binds this Attribute to an 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
Precondition
!is_bound()

Definition at line 1168 of file attributes.h.

◆ bind_if_is_compatible()

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

Binds this Attribute to an AttributesManager if it already exists in the AttributesManager and tyopes are compatible.

Parameters
[in]managera reference to the AttributesManager
[in]namename of the attribute
Precondition
!is_bound()
Returns
true if this Attribute was successfully bound

Definition at line 1212 of file attributes.h.

◆ bind_if_is_defined()

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

Binds this Attribute to an AttributesManager if it already exists in the AttributesManager.

Parameters
[in]managera reference to the AttributesManager
[in]namename of the attribute
Precondition
!is_bound()
Returns
true if this Attribute was successfully bound

Definition at line 1190 of file attributes.h.

◆ can_get_vector()

template<class T >
bool GEO::AttributeBase< T >::can_get_vector ( )
inline

Tests whether get_vector() can be called on this Attribute.

get_vector() can be called if this attribute is bound and if type T corresponds to the type used to create the attribute.

Note
Advanced users only. Most client code will not need to use this function.

Definition at line 1337 of file attributes.h.

◆ create_vector_attribute()

template<class T >
void GEO::AttributeBase< T >::create_vector_attribute ( AttributesManager manager,
const std::string &  name,
index_t  dimension 
)
inline

Creates and binds a new vector attribute.

Parameters
[in]managerthe attribute manager
[in]namethe name of the attribute
[in]dimensionthe number of elements per item

Definition at line 1237 of file attributes.h.

◆ destroy()

template<class T >
void GEO::AttributeBase< T >::destroy ( )
inline

Destroys this attribute in the AttributesManager.

On exit, the attribute is no-longer accessible in the AttributesManager, its name is available again, and this attribute is in the unbound state.

Definition at line 1256 of file attributes.h.

◆ get_vector() [1/2]

template<class T >
vector<T>& GEO::AttributeBase< T >::get_vector ( )
inline

Gets a reference to the internal vector<T> used to store the attribute.

It is forbidden to modify the size of the returned vector.

Returns
a reference to the vector<T> used to store the attribute.
Note
Advanced users only. Most client code will not need to use this function.

Definition at line 1353 of file attributes.h.

◆ get_vector() [2/2]

template<class T >
const vector<T>& GEO::AttributeBase< T >::get_vector ( ) const
inline

Gets a const reference to the internal vector<T> used to store the attribute.

Returns
a const reference to the vector<T> used to store the attribute.

Definition at line 1366 of file attributes.h.

◆ is_bound()

template<class T >
bool GEO::AttributeBase< T >::is_bound ( ) const
inline

Tests whether an Attribute is bound.

Return values
trueif this Attribute is bound
falseotherwise

Definition at line 1139 of file attributes.h.

◆ is_defined()

template<class T >
static bool GEO::AttributeBase< T >::is_defined ( AttributesManager manager,
const std::string &  name,
index_t  dim = 0 
)
inlinestatic

Tests whether an attribute with the specified name and with corresponding type exists in an AttributesManager.

Parameters
[in]managera reference to the AttributesManager
[in]namethe name of the attribute
[in]dimdimension, or 0 if any dimension can match

Definition at line 1299 of file attributes.h.

◆ manager()

template<class T >
AttributesManager* GEO::AttributeBase< T >::manager ( ) const
inline

Gets the AttributesManager this Attribute is bound to.

Returns
a pointer to the attributes manager.

Definition at line 1377 of file attributes.h.

◆ redim()

template<class T >
void GEO::AttributeBase< T >::redim ( index_t  new_dim)
inline

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
[in]new_dimthe new dimension

Definition at line 1273 of file attributes.h.

◆ size()

template<class T >
index_t GEO::AttributeBase< T >::size ( ) const
inline

Gets the size.

Returns
The number of items in this attribute.

Definition at line 1315 of file attributes.h.

◆ unbind()

template<class T >
void GEO::AttributeBase< T >::unbind ( )
inline

Unbinds this Attribute.

Precondition
is_bound()

Definition at line 1147 of file attributes.h.


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