24 #ifndef _GEMA_VECTOR_SET_H_ 25 #define _GEMA_VECTOR_SET_H_ 32 #include <QStringList> 44 bool init(
int maxNodes,
int numVectors, ...);
45 bool adjustSizes(
int maxNodes);
48 void prepareSet(
int nnodes);
51 bool containsType(
int type)
const {
return (index(type) >= 0 && _typeEnabled[type]); }
58 assert(type >= 0 && type < _nTypes);
59 if(enabled == _typeEnabled[type])
61 _typeEnabled[type] = enabled;
62 _nEnabled += (enabled ? 1 : -1);
76 void setFilled(
int type,
bool filled) { assert(index(type) >= 0); _filled.localBuffer()[index(type)] = filled; }
82 bool filled(
int type)
const { assert(index(type) >= 0);
return _filled.localBuffer()[index(type)]; }
85 int index(
int type)
const { assert(type >= 0 && type < _nTypes);
return _typeIndex[type]; }
88 int typeFromIndex(
int index)
const { assert(index >= 0 && index < _nVectors);
return _indexType[index]; }
93 assert(type >= 0 && type < _nTypes);
94 return type < _typeNames.size() ? _typeNames.at(type) :
"";
101 const GmVector&
vectorFromIndex(
int index)
const { assert(index >= 0 && index < _nVectors);
return _vectors.localBuffer()[index]; }
106 bool filledFromIndex(
int index)
const { assert(index >= 0 && index < _nVectors);
return _filled.localBuffer()[index]; }
109 bool initTypes(
int numVectors, va_list typeList);
int typeFromIndex(int index) const
Given a vector index, returns its type.
Definition: gmVectorSet.h:88
int _nTypes
The number of existing vector types.
Definition: gmVectorSet.h:111
GmTLBuffer< double, true > _vectorMemory
Memory used to hold data for the set vectors.
Definition: gmVectorSet.h:120
void fill(GmMatrix &m, const double *data, int nlin, int ncol)
Copy the contents of data to matrix m. If m size is different from nlin, ncol the matrix is resized....
Definition: gmMatrixUtils.h:51
Declaration of the GmTLBuffer class.
bool containsType(int type) const
Returns true if the vector set contains a vector of the requested type AND the type is enabled.
Definition: gmVectorSet.h:51
GmTLBuffer< GmVector, true > _vectors
Vector with vectors prepared by prepareSet()
Definition: gmVectorSet.h:121
int numEnabledTypes() const
Returns the number of enabled types in the vector set.
Definition: gmVectorSet.h:66
int index(int type) const
Returns the index inside the set of the supplied type (-1 if the type doesn't belong to the set).
Definition: gmVectorSet.h:85
int * _typeIndex
An index mapping vector types to its position within the set.
Definition: gmVectorSet.h:112
QStringList _typeNames
Optional names for vector types.
Definition: gmVectorSet.h:116
bool filled(int type) const
Returns true if the vector from the current thread, identified by its type, was marked as filled (def...
Definition: gmVectorSet.h:82
bool * _typeEnabled
A vector stating if the type is enabled or not.
Definition: gmVectorSet.h:114
void setFilled(int type, bool filled)
Marks a vector, identified by its type in the set, as filled or unfilled. IMPORTANT: The supplied typ...
Definition: gmVectorSet.h:76
bool filledFromIndex(int index) const
Returns true if the vector tied to the current thread, indentified by its index, was marked as filled...
Definition: gmVectorSet.h:106
void setTypeEnabled(int type, bool enabled)
Enables or disables a type in the set. Disabled types do NOT return vectors in calls to vector() or u...
Definition: gmVectorSet.h:56
int _nEnabled
The number of enabled vectors in _typeEnabled.
Definition: gmVectorSet.h:115
Declaration of the GmVector class.
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
GmTLBuffer< bool, true > _filled
Vector stating, for each vector, if it was filled by the user or not.
Definition: gmVectorSet.h:122
Definition: gmVectorSet.h:38
int * _indexType
Reverse index for finding the type from the vector index.
Definition: gmVectorSet.h:113
int _nVectors
The number of vectors stored in this set.
Definition: gmVectorSet.h:118
const GmVector & vectorFromIndex(int index) const
Returns a vector, tied to the current thread, identified by its index in the set.
Definition: gmVectorSet.h:101
int numVectors() const
Return the number of vectors stored in this set.
Definition: gmVectorSet.h:98
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
QString typeName(int type) const
Returns a name associated to the given type from the list supplied in the constructor.
Definition: gmVectorSet.h:91
int _maxNodes
The maximum dimension of a vector (maximum number of element nodes)
Definition: gmVectorSet.h:119