GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmStateDumpItem.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
24#ifndef _GEMA_STATE_DUMP_ITEM_H_
25#define _GEMA_STATE_DUMP_ITEM_H_
26
27#include "gmMemoryDump.h"
28
29#include "gmVector.h"
30#include "gmMatrix.h"
31
32#include "gmSingleVector.h"
33#include "gmDualVector.h"
34
35struct lua_State;
36
37class GmValueAccessor;
39class GmValueSetData;
40class GmMesh;
42class GmStateDump;
43
53{
54public:
56 virtual ~GmGroupDumpItem() {}
57
65 virtual bool addStateItemsToGroup(GmStateDump* state, int groupId) = 0;
66
70 virtual bool stateAboutToBeSaved(GmStateDump* state) { Q_UNUSED(state); return true; }
71
75 virtual bool stateSaved(GmStateDump* state) { Q_UNUSED(state); return true; }
76
80 virtual bool stateAboutToBeLoaded(GmStateDump* state) { Q_UNUSED(state); return true; }
81
85 virtual bool stateLoaded(GmStateDump* state) { Q_UNUSED(state); return true; }
86};
87
88//------------------------------------------------------------------------------
89// GmStateDumpItemTypes
90//------------------------------------------------------------------------------
91
92
99{
100 GM_AC_DUMP_ITEM = 0x01000000,
102 GM_VECTOR_DUMP_ITEM = 0x03000000,
103 GM_MATRIX_DUMP_ITEM = 0x04000000,
104 GM_BUFFER_DUMP_ITEM = 0x05000000,
105 GM_MAP_DUMP_ITEM = 0x06000000,
106 GM_LUA_DUMP_ITEM = 0x07000000,
107 GM_FILE_DUMP_ITEM = 0x08000000,
108 GM_MESH_DUMP_ITEM = 0x09000000,
109 GM_BC_DUMP_ITEM = 0x0A000000,
112 GM_DS_DUMP_ITEM = 0x0D000000,
113 GM_STREAM_DUMP_ITEM = 0x0E000000,
114 // ------------------------
115 // Do not add entries below this line
116 //-------------------------
117 GM_DUMP_ITEM_MASK = 0xFF000000,
118};
119
120//------------------------------------------------------------------------------
121// GmStateDumpBaseDataItem
122//------------------------------------------------------------------------------
123
134{
135public:
137 GmStateDumpBaseDataItem(int id, QString prefix, const GmLogCategory& logger)
138 : _id(id), _prefix(prefix), _logger(logger)
139 {
140 assert(id > 0); // The id for the function map items MUST be > 0
141 assert(_prefix.size() > 0);
142 assert(_prefix.size() < GM_MEMORY_DUMP_ITEM_NAME_SIZE - 10); // Ensure that the prefix size is not too big
143 }
144
146 int id() { return _id; }
147
149 virtual int itemSize() const { return 0; }
150
155 virtual QString itemName() const
156 {
157 QString pref = QString("%1_%2").arg(_prefix).arg(_id);
158 QString suf = nameSuffix();
159 if(!suf.isEmpty())
160 {
161 QString s = QString("%1_%2").arg(pref, suf);
163 return s;
164 }
165 return pref; // The prefix is always smaller than the maximum size
166 }
167
168protected:
169
171 virtual QString nameSuffix() const { return ""; }
172
173 int _id;
176};
177
178//------------------------------------------------------------------------------
179// GmStateDumpAccessorDataItem
180//------------------------------------------------------------------------------
181
188{
189public:
190 GmStateDumpAccessorDataItem(int id, const GmMesh* mesh, QString prefix, const GmLogCategory& logger) :
191 GmStateDumpBaseDataItem(id, prefix, logger), _mesh(mesh), _hasGeometryNodes(false) { }
192
193 virtual bool hasGeometryNodes() const { return _hasGeometryNodes; };
194 virtual const GmMesh* mesh() const { return _mesh;}
195
196protected:
197 const GmMesh* _mesh; // Mesh from which the nodes are from
198 bool _hasGeometryNodes; //Should be set from derived class -> Does the accessor has geometry nodes?
199};
200
201//------------------------------------------------------------------------------
202// GmStateDumpFunctionMapDataItem
203//------------------------------------------------------------------------------
204
214{
215public:
217 const GmLogCategory& logger, QString itemNamePrefix = "");
218
219 QString translateFunction (void* ptr, bool evaluator);
220 bool updateFunctionList();
221
222 void resetSaved() { _saved = false; }
223
224 // See comments on the base class
225 virtual int itemType() const { return GM_FUNCTIONMAP_DUMP_ITEM; }
226
227 // See comments on the base class
228 virtual bool canCompress() const { return false; }
229
230 // See comments on the base class
231 virtual bool partialOp() const { return false; }
232
233 // See comments on the base class
234 virtual bool fixedSize() const { return true; }
235
236 // See comments on the base class
237 virtual qint64 size() const { assert(!_buffer.isEmpty()); return _buffer.size(); }
238
239 // See comments on the base class. No need for a header
240 virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
241
242 virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
243 virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
244 virtual void bufferReleased(int op, bool ok);
245
246protected:
247 virtual QString nameSuffix() const;
248
249private:
252 bool _saved;
253 int _nuser;
254 int _neval;
258};
259
260//------------------------------------------------------------------------------
261// GmStateDumpValueSetDataItem
262//------------------------------------------------------------------------------
263
312{
313public:
315 const GmLogCategory& logger, bool fixed, const GmMesh* mesh, QString itemNamePrefix = "");
316
318
324 void resetSaved() { _saved = false; }
325
326 virtual int itemType() const;
327
331 int acType() const { return _acType; }
332
334 const GmMesh* mesh() const { return _mesh; }
335
336 virtual int itemSize() const;
337
338 // See comments on the base class
339 virtual bool canCompress() const { return true; }
340
341 // See comments on the base class
342 virtual bool partialOp() const { return !isDefValueSetData(); }
343
344 // See comments on the base class
345 virtual bool fixedSize() const { return _fixedHint; }
346
347 virtual qint64 size() const;
348 virtual bool fillDataHeader(char* header);
349
350 virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
351 virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
352 virtual void bufferReleased(int op, bool ok);
353
354protected:
355 virtual QString nameSuffix() const;
356
357private:
358 bool isDefValueSetData() const;
359 void initDefBuffers();
360 void fillBufferList(GmMemoryBufferList& bufferList, qint64 size, qint64 offset);
361
362 GmValueSetData* detach();
363
367 bool _saved;
373
375};
376
377//------------------------------------------------------------------------------
378// GmStateDumpArmaDataItem
379//------------------------------------------------------------------------------
380
382template <class T>
384{
385public:
386 GmStateDumpArmaDataItem(int id, T* data, const GmLogCategory& logger, bool fixed, QString itemNamePrefix)
387 : GmStateDumpBaseDataItem(id, itemNamePrefix, logger)
388 {
389 assert(id > 0);
390 assert(data);
391
392 _data = data;
393 _fixedHint = fixed;
394 }
395
396 // See comments on the base class
397 virtual int itemSize() const { return sizeof(double); }
398
399 // See comments on the base class
400 virtual bool canCompress() const { return true; }
401
402 // See comments on the base class
403 virtual bool partialOp() const { return true; }
404
405 // See comments on the base class
406 virtual bool fixedSize() const { return _fixedHint; }
407
408 // See comments on the base class
409 virtual qint64 size() const { return _data->size() * sizeof(double); }
410
411 // See comments on the base class. No need for a header
412 virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
413
414 // See comments on the base class
415 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0)
416 {
417 Q_UNUSED(size);
418 assert(size >= 0 && offset >= 0);
419 assert((unsigned)(size + offset) <= _data->size() * sizeof(double));
420 if(_data->size())
421 bufferList.addBuffer(((char*)_data->memptr()) + offset, size ? size : _data->size() * sizeof(double));
422 }
423
424 // See comments on the base class
425 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0)
426 {
427 Q_UNUSED(header);
428 assert(size > 0 && offset >= 0);
429
430 if((unsigned)(size + offset) > _data->size() * sizeof(double))
431 return false; // No growing of the vector
432 bufferList.addBuffer(((char*)_data->memptr()) + offset, size);
433 return true;
434 }
435
436private:
437 T* _data;
439};
440
441//------------------------------------------------------------------------------
442// GmStateDumpVectorDataItem
443//------------------------------------------------------------------------------
444
447{
448public:
450 GmStateDumpVectorDataItem(int id, GmVector* vec, const GmLogCategory& logger, bool fixed,
451 QString itemNamePrefix = "")
452 : GmStateDumpArmaDataItem<GmVector>(id, vec, logger, fixed, itemNamePrefix.isEmpty() ? "Vec" : itemNamePrefix) {}
453
454 // See comments on the base class
455 virtual int itemType() const { return GM_VECTOR_DUMP_ITEM; }
456};
457
458//------------------------------------------------------------------------------
459// GmStateDumpMatrixDataItem
460//------------------------------------------------------------------------------
461
464{
465public:
467 GmStateDumpMatrixDataItem(int id, GmMatrix* mat, const GmLogCategory& logger, bool fixed,
468 QString itemNamePrefix = "")
469 : GmStateDumpArmaDataItem<GmMatrix>(id, mat, logger, fixed, itemNamePrefix.isEmpty() ? "Mat" : itemNamePrefix) {}
470
471 // See comments on the base class
472 virtual int itemType() const { return GM_MATRIX_DUMP_ITEM; }
473};
474
475//------------------------------------------------------------------------------
476// GmStateDumpBufferDataItem
477//------------------------------------------------------------------------------
478
492{
493public:
494 GmStateDumpBufferDataItem(int id, char** data, int* size, int sizeMultiplier,
495 bool checkSizes, const GmLogCategory& logger, bool fixed,
496 QString itemNamePrefix = "");
497
498 GmStateDumpBufferDataItem(int id, char* data, int size, bool checkSizes,
499 const GmLogCategory& logger, bool fixed, QString itemNamePrefix = "");
500
501 void addBuffer(char** data, int* size, int sizeMultiplier);
502 void addBuffer(char* data, int size);
503
504 void clearBuffers();
505
506 // See comments on the base class
507 virtual int itemType() const { return GM_BUFFER_DUMP_ITEM; }
508
509 // See comments on the base class
510 virtual bool canCompress() const { return true; }
511
512 // See comments on the base class
513 virtual bool partialOp() const { return false; }
514
515 // See comments on the base class
516 virtual bool fixedSize() const { return _fixedHint; }
517
518 // See comments on the base class
519 virtual qint64 size() const { return _totalSize; }
520
521 virtual bool opStart(int op);
522 virtual bool opEnd (int op);
523
524 virtual bool fillDataHeader(char* header);
525
526 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
527 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
528
529private:
532 void* _data;
533 int* _size;
534 int _fsize;
536 public:
537 BufferData() : _data(NULL), _size(NULL), _fsize(0), _multiplier(0) {} // Def constructor needed by QVector
538 BufferData(char** d, int* s, int m) : _data(d), _size(s), _fsize(0), _multiplier(m) {}
539 BufferData(char* d, int s) : _data(d), _size(NULL), _fsize(s), _multiplier(1) {}
540
542 int bsize() const { return _size ? (*_size) * _multiplier : _fsize; }
543
545 char* bptr() const { return _size ? *((char**)_data) : (char*)_data; }
546 };
547
550 qint64 _totalSize;
553};
554
555//------------------------------------------------------------------------------
556// GmStateDumpSDVectorDataItem
557//------------------------------------------------------------------------------
558
567template <class Vector>
569{
570public:
574 GmStateDumpSDVectorDataItem(int id, Vector* data, bool noresize, const GmLogCategory& logger,
575 bool fixed, QString itemNamePrefix = "")
576 : GmStateDumpBaseDataItem(id, itemNamePrefix.isEmpty() ? "SDVector" : itemNamePrefix, logger)
577 {
578 S_TRACE(); assert(id > 0); assert(data);
579 _data = data;
580 _fixedHint = fixed;
581 _noresize = noresize;
582 }
583
584 // See comments on the base class
585 virtual int itemType() const { return GM_SDVECTOR_DUMP_ITEM; }
586
587 // See comments on the base class
588 virtual bool canCompress() const { return true; }
589
590 // See comments on the base class
591 virtual bool partialOp() const { return false; }
592
593 // See comments on the base class
594 virtual bool fixedSize() const { return _fixedHint; }
595
596 // See comments on the base class
597 virtual qint64 size() const { return _data->size() * sizeof(Vector::DataType); }
598
600 virtual bool fillDataHeader(char* header)
601 {
602 S_TRACE();
603 assert(GM_MEMORY_DUMP_ITEM_DATA_SIZE >= 2 * sizeof(qint64));
604
605 qint64* p = (qint64*)header;
606 p[0] = _data->numDumpBuffers();
607 assert(p[0] > 0 && p[0] <= 2);
608
609 qint64 b1 = _data->dumpBufferSize(0);
610 qint64 b2 = (p[0] == 2) ? _data->dumpBufferSize(1) : 0;
611 assert(b1 <= std::numeric_limits<qint64>::max() - b2); // No overflow expected when adding b1 & b2
612
613 p[1] = b1 + b2;
614 return true;
615 }
616
617 // See comments on the base class
618 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0)
619 {
620 S_TRACE(); Q_UNUSED(size); Q_UNUSED(offset);
621 assert(size == 0 && offset == 0); // No support for partial save
622
623 for(int i = 0, n = _data->numDumpBuffers(); i < n; i++)
624 {
625 qint64 s = _data->dumpBufferSize(i);
626 if(s)
627 bufferList.addBuffer(_data->dumpBuffer(i), s);
628 }
629 }
630
631 // See comments on the base class
632 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0)
633 {
634 S_TRACE(); Q_UNUSED(header); Q_UNUSED(offset);
635 assert(size > 0 && offset == 0);
636
637 qint64* p = (qint64*)header;
638 if(size != p[1])
639 return false; // Unexpected buffer size!
640
641 int items = (int)(size / sizeof(Vector::DataType));
642 assert(items * sizeof(Vector::DataType) == size); // size was a multiple of the item size!
643
644 if(_data->size() != items)
645 {
646 if(_noresize)
647 return false; // error. Buffers don't have the expected size and noresize was specified!
648 _data->clear();
649 _data->addValues(items);
650 }
651
652 for(int i = 0, n = _data->numDumpBuffers(); i < n; i++)
653 bufferList.addBuffer(_data->dumpBuffer(i), _data->dumpBufferSize(i));
654 return true;
655 }
656
657private:
658 Vector* _data;
661};
662
665
668
669//------------------------------------------------------------------------------
670// GmStateDumpSplitIntVecDataItem
671//------------------------------------------------------------------------------
672
689{
690public:
691 GmStateDumpSplitIntVecDataItem(int id, QList<int*>* dataList, QList<int>* sizeList, bool compact,
692 const GmLogCategory& logger, bool fixed, QString itemNamePrefix = "");
693
694 // See comments on the base class
695 virtual int itemType() const { return GM_SPLITINTVEC_DUMP_ITEM; }
696
697 // See comments on the base class
698 virtual bool canCompress() const { return true; }
699
700 // See comments on the base class
701 virtual bool partialOp() const { return false; }
702
703 // See comments on the base class
704 virtual bool fixedSize() const { return _fixedHint; }
705
706 // See comments on the base class
707 virtual qint64 size() const { return _totalSize; }
708
709 virtual bool opStart(int op);
710
711 virtual bool fillDataHeader(char* header);
712
713 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
714 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
715
716private:
717 bool _compact;
720 qint64 _totalSize;
722};
723
724//------------------------------------------------------------------------------
725// GmStateDumpMapDataItem
726//------------------------------------------------------------------------------
727
729template <class K, class V>
731{
732public:
733 GmStateDumpMapDataItem(int id, QMap<K, V>* data, bool fixedHint, const GmLogCategory& logger,
734 QString itemNamePrefix = "");
735
736 // See comments on the base class
737 virtual int itemType() const { return GM_MAP_DUMP_ITEM; }
738
739 // See comments on the base class
740 virtual bool canCompress() const { return true; }
741
742 // See comments on the base class
743 virtual bool partialOp() const { return false; }
744
745 // See comments on the base class
746 virtual bool fixedSize() const { return _fixedHint; }
747
748 virtual bool opStart(int op);
749 virtual bool opEnd(int op);
750
751 // See comments on the base class
752 virtual qint64 size() const { assert(!_data.isEmpty()); return _data.size(); }
753
754 // See comments on the base class. No need for a header
755 virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
756
757 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
758 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
759 virtual void bufferReleased(int op, bool ok);
760
761protected:
765 virtual bool fillMapData(QMap<K, V>* map) { Q_UNUSED(map); return true; }
766
771 virtual bool mapDataLoaded(QMap<K, V>* map) { Q_UNUSED(map); return true; }
772
773private:
777};
778
779//------------------------------------------------------------------------------
780// GmStateDumpVariantMapDataItem
781//------------------------------------------------------------------------------
782
785{
786public:
787 GmStateDumpVariantMapDataItem(int id, QVariantMap* data, bool fixedHint, const GmLogCategory& logger,
788 QString itemNamePrefix = "")
789 : GmStateDumpMapDataItem<QString, QVariant>(id, data, fixedHint, logger,
790 itemNamePrefix.isEmpty() ? "VarMap" : itemNamePrefix) {}
791};
792
793//------------------------------------------------------------------------------
794// GmStateDumpFileItem
795//------------------------------------------------------------------------------
796
823{
824public:
825 GmStateDumpFileItem(int id, FILE* fhandle, QString fileName, QString tempName,
826 const GmLogCategory& logger, QString itemNamePrefix = "");
827
828 // See comments on the base class
829 virtual int itemType() const { return GM_FILE_DUMP_ITEM; }
830
831protected:
832 virtual bool fillMapData (QVariantMap* map);
833 virtual bool mapDataLoaded(QVariantMap* map);
834
835private:
836 FILE* _fileh;
839 QVariantMap _dataMap;
840};
841
842//------------------------------------------------------------------------------
843// GmStateDumpLuaDataItem
844//------------------------------------------------------------------------------
845
848{
849public:
850 GmStateDumpLuaDataItem(int id, lua_State* L, const QStringList& globals,
851 const QStringList& locals, QString localTabName,
852 const GmLogCategory& logger, QString itemNamePrefix = "");
853
854 // See comments on the base class
855 virtual int itemType() const { return GM_LUA_DUMP_ITEM; }
856
857 // See comments on the base class
858 virtual bool canCompress() const { return true; }
859
860 // See comments on the base class
861 virtual bool partialOp() const { return false; }
862
863 // See comments on the base class
864 virtual bool fixedSize() const { return false; }
865
866 // See comments on the base class
867 virtual bool opStart(int op) { return op == 0 ? loadDataFromLuaState() : true; }
868
869 // See comments on the base class
870 virtual qint64 size() const { assert(!_data.isEmpty()); return _data.size(); }
871
872 // See comments on the base class. No need for a header
873 virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
874
875 virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
876 virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
877 virtual void bufferReleased(int op, bool ok);
878
879private:
880 bool loadDataFromLuaState();
881 void saveDataToLuaState();
882
883 lua_State* _L;
888};
889
890
891
893template <class T>
895{
896public:
897 GmStateDumpStreamableItem(int id, T* item, const GmLogCategory& logger,
898 QString prefix = "") : GmStateDumpBaseDataItem(id, prefix, logger), _item(item) {}
899
900 virtual bool canCompress() const { return true; }
901 virtual int itemType() const { return GM_STREAM_DUMP_ITEM; }
902 virtual bool partialOp() const { return false; }
903 virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
904
905 virtual bool fixedSize() const { return true; }
906
907 virtual bool opStart(int op);
908 virtual bool opEnd(int op);
909 virtual qint64 size() const { assert(!_data.isEmpty()); return _data.size(); }
910
911 virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
912 virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
913 virtual void bufferReleased(int op, bool ok);
914
915protected:
916 T* _item;
918};
919
920
922
923public:
924 GmStateDumpDiscontinuityStreamItem(int id, GmDiscontinuitySet* item, const GmLogCategory& logger) : GmStateDumpStreamableItem(id, item, logger, "DSet") {}
925};
926
927
928#endif
Base interface for providing discontinuity geometry information for spatial indices.
Definition gmDiscontinuitySet.h:59
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition gmStateDumpItem.h:53
virtual bool stateAboutToBeSaved(GmStateDump *state)
Virtual method called just before starting a save operation on the given state. Returning false abort...
Definition gmStateDumpItem.h:70
virtual bool stateSaved(GmStateDump *state)
Virtual method called just after succesfully completing a save operation on the given state....
Definition gmStateDumpItem.h:75
virtual ~GmGroupDumpItem()
Virtual destructor.
Definition gmStateDumpItem.h:56
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)=0
Initialization method, called once, allowing the object to add its state items to the given group of ...
virtual bool stateLoaded(GmStateDump *state)
Virtual method called just after succesfully completing a load operation on the given state....
Definition gmStateDumpItem.h:85
virtual bool stateAboutToBeLoaded(GmStateDump *state)
Virtual method called just before starting a load operation on the given state. Returning false abort...
Definition gmStateDumpItem.h:80
Class representing a category with multiple logging levels.
Definition gmLog.h:58
A helper class that can store a list of buffers and their sizes, allowing for GmMemoryDumpItem instan...
Definition gmMemoryDump.h:59
void addBuffer(char *buffer, qint64 size)
Adds another buffer to the buffer list.
Definition gmMemoryDump.cpp:207
Interface for an object that can be dumped and undumped to either file or memory by GmMemoryDump.
Definition gmMemoryDump.h:100
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
Interface responsible for providing information of mesh and if the accessors stored in derived classe...
Definition gmStateDumpItem.h:188
Class responsible for storing either a GmVector / GmMatrix object.
Definition gmStateDumpItem.h:384
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:400
virtual bool setDataBuffer(GmMemoryBufferList &bufferList, const char *header, qint64 size, qint64 offset=0)
Fills the provided bufferList object with the set of buffers that should be used to update the dump i...
Definition gmStateDumpItem.h:425
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:406
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:409
T * _data
The stored vector / matrix.
Definition gmStateDumpItem.h:437
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:438
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition gmStateDumpItem.h:412
virtual void getDataBuffer(GmMemoryBufferList &bufferList, qint64 size=0, qint64 offset=0)
Fills the provided bufferList object with the set of buffers that together define the dump item data.
Definition gmStateDumpItem.h:415
virtual int itemSize() const
The item size needed for calculating sizes and offsets in bytes for partial updates....
Definition gmStateDumpItem.h:397
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:403
Ensure that all dump items stored by GmStateDump have an id() and a logger.
Definition gmStateDumpItem.h:134
QString _prefix
The object name prefix.
Definition gmStateDumpItem.h:174
virtual QString itemName() const
Returns the default item name composed of the object prefix + '' + the object id, optionally followed...
Definition gmStateDumpItem.h:155
GmStateDumpBaseDataItem(int id, QString prefix, const GmLogCategory &logger)
Constructor.
Definition gmStateDumpItem.h:137
const GmLogCategory & _logger
Basic logger object for dump messages.
Definition gmStateDumpItem.h:175
virtual QString nameSuffix() const
Virtual method returning the extra part of the item name, added to its standard prefix.
Definition gmStateDumpItem.h:171
virtual int itemSize() const
The item size needed for calculating sizes and offsets in bytes for partial updates....
Definition gmStateDumpItem.h:149
int id()
Returns the internal dump item id.
Definition gmStateDumpItem.h:146
int _id
The object id.
Definition gmStateDumpItem.h:173
Helper structure to store a tuple (buffer ptr, size ptr, size multiplier)
Definition gmStateDumpItem.h:531
int _multiplier
Multiplier to transform (*_size) into bytes or 1 if _fsize was filled.
Definition gmStateDumpItem.h:535
int _fsize
A fixed size for _data (in bytes), valid when _size is NULL.
Definition gmStateDumpItem.h:534
void * _data
Either a pointer to the buffer pointer (char**) or a pointer to the buffer (char*)
Definition gmStateDumpItem.h:532
int * _size
Pointer to the buffer size.
Definition gmStateDumpItem.h:533
char * bptr() const
Returns the buffer pointer.
Definition gmStateDumpItem.h:545
int bsize() const
Returns the buffer size in bytes.
Definition gmStateDumpItem.h:542
Class responsible for storing one or more user buffer objects.
Definition gmStateDumpItem.h:492
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:507
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:551
bool _checkSizes
When restoring, individual buffer sizes should be checked?
Definition gmStateDumpItem.h:552
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:519
QVector< BufferData > _bufferDataList
The stored data + size.
Definition gmStateDumpItem.h:548
qint64 _totalSize
The sum of the sizes in _sizes when the operation started.
Definition gmStateDumpItem.h:550
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:516
QVector< int > _sizes
The current buffer sizes when the operation started.
Definition gmStateDumpItem.h:549
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:513
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:510
Definition gmStateDumpItem.h:921
Class responsible for storing the needed data to rollback an "append only" file to a previous state.
Definition gmStateDumpItem.h:823
FILE * _fileh
The file handle.
Definition gmStateDumpItem.h:836
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:829
QString _fileName
The actual file name for fileh. Might be different from _baseName when working with temp files.
Definition gmStateDumpItem.h:838
QString _baseName
The base file name. Should be equal to the same data when restored.
Definition gmStateDumpItem.h:837
QVariantMap _dataMap
The stored variant map.
Definition gmStateDumpItem.h:839
Class responsible for storing a table mapping function pointers (either an user function or a functio...
Definition gmStateDumpItem.h:214
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:234
bool _saved
Has this dump item been saved at least once?
Definition gmStateDumpItem.h:252
int _neval
The number of evaluators on the _getBuffer.
Definition gmStateDumpItem.h:254
GmValueAccessor * _ac1
The accessor object providing the stored data.
Definition gmStateDumpItem.h:250
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:228
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:231
int _nuser
The number of user function entries on the _getBuffer.
Definition gmStateDumpItem.h:253
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:237
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition gmStateDumpItem.h:240
QVarLengthArray< char > _buffer
The buffer used by getDataBuffer() / setDataBuffer()
Definition gmStateDumpItem.h:255
QMap< void *, QString > _evalMap
The map translating loaded function evaluator pointers to user function Ids.
Definition gmStateDumpItem.h:257
QMap< void *, QString > _userMap
The map translating loaded user function pointers to user function Ids.
Definition gmStateDumpItem.h:256
GmValueAccessor * _ac2
A second accessor object used when working with ghost accessors. Can be NULL.
Definition gmStateDumpItem.h:251
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:225
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition gmStateDump.h:54
Class responsible for storing Lua global / local values.
Definition gmStateDumpItem.h:848
QStringList _globals
The name of the global variables to be saved/loaded.
Definition gmStateDumpItem.h:884
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition gmStateDumpItem.h:873
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:858
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:864
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:855
virtual bool opStart(int op)
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryD...
Definition gmStateDumpItem.h:867
lua_State * _L
The Lua state where the values will be loaded/saved.
Definition gmStateDumpItem.h:883
QByteArray _data
The serialized data.
Definition gmStateDumpItem.h:887
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:861
QStringList _locals
The name of the local variables to be saved/loaded.
Definition gmStateDumpItem.h:885
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:870
QString _localTabName
The name of the table used to store local variable values.
Definition gmStateDumpItem.h:886
Class responsible for storing a QMap of values. Useful for storing generic sets of "scalar" attribute...
Definition gmStateDumpItem.h:731
QByteArray _data
The serialized data.
Definition gmStateDumpItem.h:776
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:737
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:746
virtual bool fillMapData(QMap< K, V > *map)
A virtual function called just before a save operation that can be used by derived classes to fill th...
Definition gmStateDumpItem.h:765
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:752
virtual bool mapDataLoaded(QMap< K, V > *map)
A virtual function called just after a load operation that can be used by derived classes to validate...
Definition gmStateDumpItem.h:771
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:743
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:775
QMap< K, V > * _varMap
The stored map.
Definition gmStateDumpItem.h:774
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition gmStateDumpItem.h:755
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:740
Class responsible for storing a GmMatrix object.
Definition gmStateDumpItem.h:464
GmStateDumpMatrixDataItem(int id, GmMatrix *mat, const GmLogCategory &logger, bool fixed, QString itemNamePrefix="")
Constructor.
Definition gmStateDumpItem.h:467
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:472
Class responsible for storing a GmSingleVector or a GmDualVector.
Definition gmStateDumpItem.h:569
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:585
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:597
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:594
virtual bool fillDataHeader(char *header)
Fills a header with the number of stored buffers (1 or 2) and their sizes.
Definition gmStateDumpItem.h:600
virtual bool setDataBuffer(GmMemoryBufferList &bufferList, const char *header, qint64 size, qint64 offset=0)
Fills the provided bufferList object with the set of buffers that should be used to update the dump i...
Definition gmStateDumpItem.h:632
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:659
GmStateDumpSDVectorDataItem(int id, Vector *data, bool noresize, const GmLogCategory &logger, bool fixed, QString itemNamePrefix="")
Constructor. The fixed parameter is a hint on the buffers changing size over time or not....
Definition gmStateDumpItem.h:574
bool _noresize
States that the buffers should not be automatically reside on a restore.
Definition gmStateDumpItem.h:660
Vector * _data
The stored vector (either a GmSingleVector or a GmDualVector)
Definition gmStateDumpItem.h:658
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:588
virtual void getDataBuffer(GmMemoryBufferList &bufferList, qint64 size=0, qint64 offset=0)
Fills the provided bufferList object with the set of buffers that together define the dump item data.
Definition gmStateDumpItem.h:618
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:591
Class responsible for storing the contents provided by a list of int vectors, each with its own size,...
Definition gmStateDumpItem.h:689
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:721
QList< int * > * _dataList
The data list.
Definition gmStateDumpItem.h:718
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:695
qint64 _totalSize
The sum of the sizes in _sizeLists when the operation started.
Definition gmStateDumpItem.h:720
bool _compact
Is this a compact list? See the class description.
Definition gmStateDumpItem.h:717
QList< int > * _sizeList
The sizes for each vector in _dataList.
Definition gmStateDumpItem.h:719
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:704
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:707
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:698
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:701
General class for QT streamable objects.
Definition gmStateDumpItem.h:895
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:905
T * _item
The stored item.
Definition gmStateDumpItem.h:916
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:902
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:900
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition gmStateDumpItem.h:903
QByteArray _data
The serialized data.
Definition gmStateDumpItem.h:917
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:901
virtual qint64 size() const
Returns the current item size (in bytes)
Definition gmStateDumpItem.h:909
A GmMemoryDumpItem implementation loading / storing values from the GmValueSetData object associated ...
Definition gmStateDumpItem.h:312
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition gmStateDumpItem.h:342
const GmMesh * mesh() const
Returns the mesh registered by the constructor.
Definition gmStateDumpItem.h:334
int _acType
Acessor type (0 = normal, 1 = geometry part of ghost ac and 2 = ghost part of ghost ac)
Definition gmStateDumpItem.h:365
int _defBufferSize
The size of the def buffers.
Definition gmStateDumpItem.h:371
char * _defSetBuffer
The internal buffer used by set operations for default value sets.
Definition gmStateDumpItem.h:370
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition gmStateDumpItem.h:339
int _loadMode
-1 = set not called, 0 = data on value set, 1 = data on defSetBuffer is double vec,...
Definition gmStateDumpItem.h:372
virtual bool fixedSize() const
Is this dump item a fixed size item that probably won't grow in the future? If so,...
Definition gmStateDumpItem.h:345
bool _isPacked
Is this a packed value set?
Definition gmStateDumpItem.h:368
bool _fixedHint
Does this object has a low probability of growing?
Definition gmStateDumpItem.h:366
bool _saved
Has this dump item been saved at least once?
Definition gmStateDumpItem.h:367
int acType() const
Returns the accessor type received on the object constructor (0 = normal, 1 = normal part of ghost ac...
Definition gmStateDumpItem.h:331
GmTrackedValueAccessor * _ac
The accessor object providing the stored data.
Definition gmStateDumpItem.h:364
char * _defGetBuffer
The internal buffer used by get operations for default value sets.
Definition gmStateDumpItem.h:369
GmStateDumpFunctionMapDataItem * _functionMap
The map used to translate function pointers to and from function ids.
Definition gmStateDumpItem.h:374
void resetSaved()
Resets the flag stating whether this item has already been saved or not. This operation is needed if ...
Definition gmStateDumpItem.h:324
Class responsible for a QVariantMap of values. Useful for storing generic sets of "scalar" attributes...
Definition gmStateDumpItem.h:785
Class responsible for storing a GmVector object.
Definition gmStateDumpItem.h:447
virtual int itemType() const
Returns the item type.
Definition gmStateDumpItem.h:455
GmStateDumpVectorDataItem(int id, GmVector *vec, const GmLogCategory &logger, bool fixed, QString itemNamePrefix="")
Constructor.
Definition gmStateDumpItem.h:450
Auxiliary class responisble for allowing a value accessor to track changes to the referenced value se...
Definition gmTrackedValueAccessor.h:38
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base cl...
Definition gmValueSetData.h:58
#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
Implementation of the GmDualVector and GmDualVectorR template classes.
Declaration of the GmMatrix class.
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
Declaration of the GmMemoryDump and GmMemoryDumpItem classes.
#define GM_MEMORY_DUMP_ITEM_NAME_SIZE
The maximum size for a dump item name.
Definition gmMemoryDump.h:46
#define GM_MEMORY_DUMP_ITEM_DATA_SIZE
The size of the per item fixed item data buffer.
Definition gmMemoryDump.h:49
Implementation of the GmSingleVector template class.
GmStateDumpSDVectorDataItem< GmDualVector< int > > GmStateDumpDualVectorIntDataItem
A GmStateDumpSDVectorDataItem for a GmDualVector<int>
Definition gmStateDumpItem.h:667
GmStateDumpSDVectorDataItem< GmSingleVector< int > > GmStateDumpSingleVectorIntDataItem
A GmStateDumpSDVectorDataItem for a GmSingleVector<int>
Definition gmStateDumpItem.h:664
GmStateDumpItemTypes
The set of possible Dump item types formed by an or of the Base type given by this enumeration with l...
Definition gmStateDumpItem.h:99
@ GM_MESH_DUMP_ITEM
Dump item for mesh objects.
Definition gmStateDumpItem.h:108
@ GM_BUFFER_DUMP_ITEM
Dump item for multiple user buffers.
Definition gmStateDumpItem.h:104
@ GM_FILE_DUMP_ITEM
Dump item for "Append only" files.
Definition gmStateDumpItem.h:107
@ GM_MATRIX_DUMP_ITEM
Dump item for GmMatrix values.
Definition gmStateDumpItem.h:103
@ GM_LUA_DUMP_ITEM
Dump item for Lua global/local variables.
Definition gmStateDumpItem.h:106
@ GM_BC_DUMP_ITEM
Dump item for Boundary condition objects.
Definition gmStateDumpItem.h:109
@ GM_DUMP_ITEM_MASK
Mask for the high bits defining the basic dump item type.
Definition gmStateDumpItem.h:117
@ GM_SDVECTOR_DUMP_ITEM
Dump item for a GmSingleVector or a GmDualVector.
Definition gmStateDumpItem.h:111
@ GM_FUNCTIONMAP_DUMP_ITEM
Dump item for mapping function pointers to function names.
Definition gmStateDumpItem.h:101
@ GM_SPLITINTVEC_DUMP_ITEM
Dump item for a list of int vectors.
Definition gmStateDumpItem.h:110
@ GM_AC_DUMP_ITEM
Dump item for accessor values.
Definition gmStateDumpItem.h:100
@ GM_STREAM_DUMP_ITEM
Dump item for streamable items.
Definition gmStateDumpItem.h:113
@ GM_VECTOR_DUMP_ITEM
Dump item for GmVector values.
Definition gmStateDumpItem.h:102
@ GM_DS_DUMP_ITEM
Dump item for Discontinuity Set.
Definition gmStateDumpItem.h:112
@ GM_MAP_DUMP_ITEM
Dump item for a QMap.
Definition gmStateDumpItem.h:105
#define S_TRACE()
Macro for run time stack tracking at release build.
Definition gmTrace.h:44
Declaration of the GmVector class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isEmpty() const const
void truncate(int position)