Radium Engine
1.5.0
|
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 = std::function< void(Args...)> |
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. More... | |
template<typename T > | |
AttribHandle< T > | findAttrib (const std::string &name) const |
findAttrib Grab an attribute handler by name . More... | |
template<typename T > | |
Attrib< T >::Container & | getDataWithLock (const AttribHandle< T > &h) |
Get the locked data container from the attrib handle. More... | |
template<typename T > | |
const Attrib< T >::Container & | getData (const AttribHandle< T > &h) |
Get read access to the data container from the attrib handle. More... | |
template<typename T > | |
void | unlock (const AttribHandle< T > &h) |
Unlock the handle data. More... | |
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.
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 712 of file Attribs.hpp.
|
inline |
contains Check if an attribute with the given name
exists.
name | Name of the attribute. |
Definition at line 618 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.
void Ra::Core::Utils::AttribManager::copyAttributes | ( | const AttribManager & | m, |
const AttribHandle< T > & | attr, | ||
Handle... | attribs | ||
) |
Copy the given attributes from m
.
Definition at line 597 of file Attribs.hpp.
|
inline |
findAttrib Grab an attribute handler by name
.
name | Name of the attribute. |
Definition at line 623 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::for_each_attrib | ( | const F & | func | ) | const |
Perform fun
on each attribute.
Definition at line 755 of file Attribs.hpp.
|
inline |
Get attribute by handle.
Definition at line 649 of file Attribs.hpp.
|
inline |
Get attribute by name. First search name to index correpondance
Definition at line 658 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 689 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 639 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 634 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.
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 740 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 678 of file Attribs.hpp.
|
inline |
Definition at line 684 of file Attribs.hpp.
void Ra::Core::Utils::AttribManager::unlock | ( | const AttribHandle< T > & | h | ) |
Unlock the handle data.
T |
h |
Definition at line 644 of file Attribs.hpp.