GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmValueSetGroup.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
23#ifndef _GEMA_VALUE_SET_GROUP_H_
24#define _GEMA_VALUE_SET_GROUP_H_
25
26#include "gmCoreConfig.h"
27#include "gmValueSet.h"
28
29#include <QVector>
30
31
38{
39public:
41
42 virtual ~GmValueSetGroup();
43
44 virtual bool addValueSet (QString id, GmValueInfo* info);
45 virtual bool removeValueSet(QString id, bool releaseInfo = false);
46
48 bool isEmpty() const { return _valueSets.isEmpty(); }
49
51 int numSets() const { return _valueSets.size(); }
52
53 void addValueSetBegin();
54 bool addValueSetEnd();
55
57 bool insideAddBlock() const { return _insideBlock >= 0; }
58
59 int nextNewPack() const;
60
61 virtual bool init(int numValues);
62
64 bool initialized() const { return _init; }
65
67 int numValues() const { return _numValues; }
68
69 virtual bool addValues (int numAddedValues);
70 virtual void removeValues(int index, int numValues);
71 virtual void restoreSize (int oldSize);
72
73 virtual void clear();
74 virtual void clearData();
75
76 virtual bool saveState(GmValueSet::SaveStateMode mode, const GmLogCategory& logger);
77
79 const QMap<QString, int>& dataMap() const { return _idMap; }
80
82 bool contains(QString id) const { return _idMap.contains(id); }
83
88 const QVector<GmValueSet*>& valueSets() const { return _valueSets; }
89
91 GmValueSet* valueSet(QString id) const { int i = _idMap.value(id, -1); return (i == -1) ? NULL : _valueSets.at(i); }
92
93 virtual size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const;
94 virtual size_t usedMemory() const;
95
96#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
97 virtual void validateInternalStructure();
98#endif
99
100protected:
102 virtual GmValueSet* createValueSet(GmValueInfo* info, GmPackedBuffer* pack) { return new GmValueSet(info, pack, _simData, _mesh); }
103
104 GmPackedBuffer* getPack(int packId);
105
108 bool _init;
111
115
116private:
117 Q_DISABLE_COPY(GmValueSetGroup)
118};
119
120#endif
121
122
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
The basic interface for a shared buffer storing interleaved data for a group of value sets.
Definition gmPackedBuffer.h:119
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
This class manages a group of ValueSets that have all the same size and must grow (or shrink) togethe...
Definition gmValueSetGroup.h:38
bool insideAddBlock() const
Returns true if addValueSetBegin() has been called without a matching addValueSetEnd() call.
Definition gmValueSetGroup.h:57
virtual GmValueSet * createValueSet(GmValueInfo *info, GmPackedBuffer *pack)
Virtual function used to create the stored value set. Can be overwritten by descendant classes.
Definition gmValueSetGroup.h:102
bool contains(QString id) const
Returns true if the group contains a value set for an attribute named id.
Definition gmValueSetGroup.h:82
QMap< int, GmPackedBuffer * > _packs
A map indexing packed buffers by their id.
Definition gmValueSetGroup.h:114
int _numValues
The size of the stored value sets.
Definition gmValueSetGroup.h:110
bool isEmpty() const
Returns true if this group is empty (does not include any value set).
Definition gmValueSetGroup.h:48
const QVector< GmValueSet * > & valueSets() const
Returns a list with the stored value sets. The map returned by dataMap() is an index onto this list....
Definition gmValueSetGroup.h:88
int numSets() const
Returns the number of sets stored in this group.
Definition gmValueSetGroup.h:51
QVector< GmValueSet * > _valueSets
The list of stored value sets.
Definition gmValueSetGroup.h:113
bool _init
Have we been initialized yet?
Definition gmValueSetGroup.h:108
GmSimulationData * _simData
The simulation data object. Needed for value sets accepting function values. Might be NULL.
Definition gmValueSetGroup.h:106
GmValueSet * valueSet(QString id) const
Returns the value set associated with the given data id. Returns NULL if not found.
Definition gmValueSetGroup.h:91
GmMesh * _mesh
The associated mesh object. Needed for most value sets accepting function values (except property set...
Definition gmValueSetGroup.h:107
QMap< QString, int > _idMap
Maps stored value set ids to their position in _valueSets.
Definition gmValueSetGroup.h:112
const QMap< QString, int > & dataMap() const
Returns a map indexed by value set data id, storing the id position in the value set list.
Definition gmValueSetGroup.h:79
int _insideBlock
Are we inside an addValueSetBegin / End block? If inside, stores the index in _valueSets of the first...
Definition gmValueSetGroup.h:109
bool initialized() const
Returns true if the group has been initialized with a call to init()
Definition gmValueSetGroup.h:64
int numValues() const
Returns the size (number of "entries") of the stored value sets.
Definition gmValueSetGroup.h:67
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition gmValueSet.h:54
SaveStateMode
Initialization mode for calls to saveState()
Definition gmValueSet.h:60
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
GmLogLevel
Available log levels list.
Definition gmLog.h:36
Declaration of the GmValueSet class.