Radium Engine
1.5.20
|
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> |
Public Types inherited from Ra::Core::Utils::Observable< const std::string & > | |
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) |
Public Member Functions inherited from Ra::Core::Utils::Observable< const std::string & > | |
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 203 of file Attribs.hpp.
Definition at line 209 of file Attribs.hpp.
Definition at line 207 of file Attribs.hpp.
Definition at line 208 of file Attribs.hpp.
Definition at line 206 of file Attribs.hpp.
|
inline |
Definition at line 577 of file Attribs.hpp.
|
inline |
Definition at line 579 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 711 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 617 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 591 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 596 of file Attribs.hpp.
|
inline |
findAttrib Grab an attribute handler by name
.
name | Name of the attribute. |
Definition at line 622 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::for_each_attrib | ( | const F & | func | ) |
Definition at line 760 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::for_each_attrib | ( | const F & | func | ) | const |
Perform fun
on each attribute.
Definition at line 754 of file Attribs.hpp.
|
inline |
Get attribute by handle.
Definition at line 648 of file Attribs.hpp.
|
inline |
Definition at line 653 of file Attribs.hpp.
|
inline |
Get attribute by name. First search name to index correpondance
Definition at line 657 of file Attribs.hpp.
|
inline |
Definition at line 662 of file Attribs.hpp.
|
inline |
Definition at line 700 of file Attribs.hpp.
|
inline |
Definition at line 705 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 688 of file Attribs.hpp.
|
inline |
Definition at line 694 of file Attribs.hpp.
|
inline |
Definition at line 667 of file Attribs.hpp.
|
inline |
Definition at line 672 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 638 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 633 of file Attribs.hpp.
|
inline |
Return the number of attributes.
Definition at line 765 of file Attribs.hpp.
|
inline |
Returns a scope unlocker for managed attribs.
Definition at line 429 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 612 of file Attribs.hpp.
|
inline |
Definition at line 584 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 739 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 677 of file Attribs.hpp.
|
inline |
Definition at line 683 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::unlock | ( | const AttribHandle< T > & | h | ) |
Unlock the handle data.
T |
h |
Definition at line 643 of file Attribs.hpp.
|
friend |
Definition at line 440 of file Attribs.hpp.