The AttribManager provides attributes management by handles. More...
#include <Core/Utils/Attribs.hpp>
Classes | |
class | ScopedLockState |
Scope lock state management for attributes. More... | |
Public Types | |
using | value_type = AttribBase |
using | pointer_type = value_type* |
using | smart_pointer_type = std::unique_ptr<value_type> |
using | Container = std::vector<smart_pointer_type> |
![]() | |
using | Observer |
Observer functor type. | |
Public Member Functions | |
AttribManager (const AttribManager &m)=delete | |
Copy constructor and assignment operator are forbidden. | |
AttribManager & | operator= (const AttribManager &m)=delete |
AttribManager (AttribManager &&m) | |
AttribManager & | operator= (AttribManager &&m) |
void | copyAttributes (const AttribManager &m) |
Base copy, does nothing. | |
template<class T , class... Handle> | |
void | copyAttributes (const AttribManager &m, const AttribHandle< T > &attr, Handle... attribs) |
void | copyAllAttributes (const AttribManager &m) |
void | clear () |
clear all attribs, invalidate handles. | |
template<typename T > | |
bool | isValid (const AttribHandle< T > &h) const |
Return true if h correspond to an existing attribute in *this. | |
bool | contains (const std::string &name) const |
contains Check if an attribute with the given name exists. | |
template<typename T > | |
AttribHandle< T > | findAttrib (const std::string &name) const |
findAttrib Grab an attribute handler by name . | |
template<typename T > | |
Attrib< T >::Container & | getDataWithLock (const AttribHandle< T > &h) |
Get the locked data container from the attrib handle. | |
template<typename T > | |
const Attrib< T >::Container & | getData (const AttribHandle< T > &h) |
Get read access to the data container from the attrib handle. | |
template<typename T > | |
void | unlock (const AttribHandle< T > &h) |
Unlock the handle data. | |
template<typename T > | |
AttribHandle< T > | addAttrib (const std::string &name) |
template<typename T > | |
void | removeAttrib (AttribHandle< T > &h) |
bool | hasSameAttribs (const AttribManager &other) |
int | getNumAttribs () const |
Return the number of attributes. | |
ScopedLockState | getScopedLockState () |
Returns a scope unlocker for managed attribs. | |
template<typename T > | |
Attrib< T > & | getAttrib (const AttribHandle< T > &h) |
template<typename T > | |
const Attrib< T > & | getAttrib (const AttribHandle< T > &h) const |
template<typename T > | |
Attrib< T > * | getAttribPtr (const AttribHandle< T > &h) |
template<typename T > | |
const Attrib< T > * | getAttribPtr (const AttribHandle< T > &h) const |
template<typename T > | |
Attrib< T > & | getAttrib (const std::string &name) |
template<typename T > | |
const Attrib< T > & | getAttrib (const std::string &name) const |
AttribBase * | getAttribBase (const std::string &name) |
const AttribBase * | getAttribBase (const std::string &name) const |
AttribBase * | getAttribBase (const Index &idx) |
const AttribBase * | getAttribBase (const Index &idx) const |
template<typename T > | |
void | setAttrib (const AttribHandle< T > &h, const typename AttribHandle< T >::Container &data) |
template<typename T > | |
void | setAttrib (const AttribHandle< T > &h, typename AttribHandle< T >::Container &&data) |
template<typename F > | |
void | for_each_attrib (const F &func) const |
template<typename F > | |
void | for_each_attrib (const F &func) |
![]() | |
Observable ()=default | |
Default constructor ... do nothing ;) | |
Observable (const Observable &)=delete | |
Observable & | operator= (const Observable &)=delete |
void | copyObserversTo (Observable &other) const |
explicit copy of all attached observers the other Observable | |
int | attach (Observer observer) |
int | attachMember (T *object, void(T::*observer)(Args...)) |
void | notify (Args... p) const |
Notify (i.e. call) each attached observer with argument p . | |
void | detachAll () |
Detach all observers. | |
void | detach (int observerId) |
Friends | |
class | ::Ra::Core::Geometry::TopologicalMesh |
The AttribManager provides attributes management by handles.
The AttribManager stores a container of AttribBase *, which can be accessed (getAttrib) and deleted (removeAttrib) using a AttribHandle. Handles are created from an attribute name using addAttrib, and retrieved using findAttrib.
Example of typical use case:
Definition at line 211 of file Attribs.hpp.
Definition at line 217 of file Attribs.hpp.
Definition at line 215 of file Attribs.hpp.
Definition at line 216 of file Attribs.hpp.
Definition at line 214 of file Attribs.hpp.
|
inline |
Definition at line 585 of file Attribs.hpp.
|
inline |
Definition at line 587 of file Attribs.hpp.
|
override |
Definition at line 13 of file Attribs.cpp.
AttribHandle< T > Ra::Core::Utils::AttribManager::addAttrib | ( | const std::string & | name | ) |
Add attribute by name. notify(name) is called to trigger the observers
Definition at line 719 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::clear | ( | ) |
clear all attribs, invalidate handles.
Definition at line 17 of file Attribs.cpp.
|
inline |
contains Check if an attribute with the given name
exists.
name | Name of the attribute. |
Definition at line 625 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::copyAllAttributes | ( | const AttribManager & | m | ) |
Copy all attributes from m
.
Definition at line 23 of file Attribs.cpp.
|
inline |
Base copy, does nothing.
Definition at line 599 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::copyAttributes | ( | const AttribManager & | m, |
const AttribHandle< T > & | attr, | ||
Handle... | attribs ) |
Copy the given attributes from m
.
Definition at line 604 of file Attribs.hpp.
|
inline |
findAttrib Grab an attribute handler by name
.
name | Name of the attribute. |
Definition at line 630 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::for_each_attrib | ( | const F & | func | ) |
Definition at line 768 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::for_each_attrib | ( | const F & | func | ) | const |
Perform fun
on each attribute.
Definition at line 762 of file Attribs.hpp.
|
inline |
Get attribute by handle.
Definition at line 656 of file Attribs.hpp.
|
inline |
Definition at line 661 of file Attribs.hpp.
|
inline |
Get attribute by name. First search name to index correpondance
Definition at line 665 of file Attribs.hpp.
|
inline |
Definition at line 670 of file Attribs.hpp.
|
inline |
Definition at line 708 of file Attribs.hpp.
|
inline |
Definition at line 713 of file Attribs.hpp.
|
inline |
Return a AttribBase ptr to the attrib identified by name. to give access to AttribBase method, regardless of the type of element stored in the attrib.
Definition at line 696 of file Attribs.hpp.
|
inline |
Definition at line 702 of file Attribs.hpp.
|
inline |
Definition at line 675 of file Attribs.hpp.
|
inline |
Definition at line 680 of file Attribs.hpp.
const Attrib< T >::Container & Ra::Core::Utils::AttribManager::getData | ( | const AttribHandle< T > & | h | ) |
Get read access to the data container from the attrib handle.
T | The type of the attribute data |
h | the attribute handle |
Definition at line 646 of file Attribs.hpp.
Attrib< T >::Container & Ra::Core::Utils::AttribManager::getDataWithLock | ( | const AttribHandle< T > & | h | ) |
Get the locked data container from the attrib handle.
T | The type of the attribute data |
h | the attribute handle |
Definition at line 641 of file Attribs.hpp.
|
inline |
Return the number of attributes.
Definition at line 773 of file Attribs.hpp.
|
inline |
Returns a scope unlocker for managed attribs.
Definition at line 437 of file Attribs.hpp.
bool Ra::Core::Utils::AttribManager::hasSameAttribs | ( | const AttribManager & | other | ) |
Return true if *this and other
have the same attributes, same amount and same names.
Definition at line 33 of file Attribs.cpp.
bool Ra::Core::Utils::AttribManager::isValid | ( | const AttribHandle< T > & | h | ) | const |
Return true if h
correspond to an existing attribute in *this.
Definition at line 620 of file Attribs.hpp.
|
inline |
Definition at line 592 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::removeAttrib | ( | AttribHandle< T > & | h | ) |
Remove attribute by handle, invalidates the handle. notify(name) is called to trigger the observers
Definition at line 747 of file Attribs.hpp.
|
inline |
Set the data of the attrib h.
h
has to be a valid attrib handle, this is not checked. Definition at line 685 of file Attribs.hpp.
|
inline |
Definition at line 691 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::unlock | ( | const AttribHandle< T > & | h | ) |
Unlock the handle data.
T |
h |
Definition at line 651 of file Attribs.hpp.
|
friend |
Definition at line 448 of file Attribs.hpp.