![]() |
GemaCoreLib
The GeMA Core library
|
A helper class implementing common code for handling group sets, specially handling group nodes. Is inherited by GmCellDisjointGroupSet and by GmCellGenericGroupSet. More...
#include <gmCellGroupSet.h>
Public Member Functions | |
virtual | ~GmBaseCellGroupSet () |
Destructor. | |
virtual int | numNodes () const |
Returns the number of nodes shared by the group elements. | |
virtual int | node (int setIndex) const |
Given an index in the range [0..numNodes()-1], returns the respective mesh node index. | |
virtual void | clear () |
Clear the group set in response to a mesh clear() opeartion. It will not clear the list of cellGroups. | |
virtual const QList< int > & | cellGroups () const |
Returns a list with the cell groups belonging to this group set. Values are the group index in the mesh, ordered by index. | |
virtual GmCellMesh * | mesh () const |
Returns the mesh owning the cell groups. | |
![]() | |
virtual int | numCells () const =0 |
Returns the number of unique elements in the cell group set. | |
virtual GmCell * | cell (int setIndex) const =0 |
Given an index in the range [0..numCells()-1], returns the respective cell. | |
virtual bool | ordered () const =0 |
Returns true if the the set returned by calls to cell(0) through cell(numCells()-1) is ordered by cell id. | |
QStringList | cellGroupNames () const |
Returns the result of cellGroups() converted to group names. | |
Protected Types | |
typedef QPair< int, int * > | NodeData |
Type for storing node data information: Number of nodes + vector pointer. | |
Protected Member Functions | |
GmBaseCellGroupSet (GmCellMesh *mesh, const QList< int > &groups) | |
Base group set constructor. Stores the mesh and an ordered version of the group list. | |
NodeData * | buildNodeList () const |
Builds the list with nodes used by this element groups. Does not changes the internal state. | |
NodeData * | nodeData () const |
Auxiliar function that uses the Double Checked Locking Pattern (DCLP) to grab. More... | |
Protected Attributes | |
GmCellMesh * | _mesh |
The associated mesh. | |
QList< int > | _groupList |
The list of mesh cell groups included in this set. | |
QAtomicPointer< NodeData > | _nodeData |
Atomic pointer to the node data. Contains the number of nodes shared by the group cells and a vector with node indices. Mutable so that it can be filled in a lazy way by nodeData(). Stored in an atomic pointer to enable the use of a DCLP. | |
QMutex | _nodeDataMutex |
Mutex protecting the creation of _nodeData. | |
Additional Inherited Members | |
![]() | |
static bool | cellGroupIds (const GmCellMesh *mesh, const QStringList &groupNames, QList< int > &idList, QString &err) |
Given a set of cell group names, creates a set of group ids, filling idList. More... | |
A helper class implementing common code for handling group sets, specially handling group nodes. Is inherited by GmCellDisjointGroupSet and by GmCellGenericGroupSet.
Node data is filled in a lazy way only if numNodes() or node() are ever called.
|
protected |
Auxiliar function that uses the Double Checked Locking Pattern (DCLP) to grab.
the pointer to the node data, creating it by calling buildNodeList() if the node data was not created yet..
Using DCLP guranteees that all accesses but the first one have minimum overhead.
See https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/ for an extensive documentation about the DCLP problem.