GemaCoreLib
The GeMA Core library
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 
35 struct lua_State;
36 
37 class GmValueAccessor;
39 class GmValueSetData;
40 class GmMesh;
41 
42 class GmStateDump;
43 
53 {
54 public:
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,
111  GM_SDVECTOR_DUMP_ITEM = 0x0C000000,
112  // ------------------------
113  // Do not add entries below this line
114  //-------------------------
115  GM_DUMP_ITEM_MASK = 0xFF000000,
116 };
117 
118 //------------------------------------------------------------------------------
119 // GmStateDumpBaseDataItem
120 //------------------------------------------------------------------------------
121 
132 {
133 public:
135  GmStateDumpBaseDataItem(int id, QString prefix, const GmLogCategory& logger)
136  : _id(id), _prefix(prefix), _logger(logger)
137  {
138  assert(id > 0); // The id for the function map items MUST be > 0
139  assert(_prefix.size() > 0);
140  assert(_prefix.size() < GM_MEMORY_DUMP_ITEM_NAME_SIZE - 10); // Ensure that the prefix size is not too big
141  }
142 
144  int id() { return _id; }
145 
147  virtual int itemSize() const { return 0; }
148 
153  virtual QString itemName() const
154  {
155  QString pref = QString("%1_%2").arg(_prefix).arg(_id);
156  QString suf = nameSuffix();
157  if(!suf.isEmpty())
158  {
159  QString s = QString("%1_%2").arg(pref, suf);
161  return s;
162  }
163  return pref; // The prefix is always smaller than the maximum size
164  }
165 
166 protected:
167 
169  virtual QString nameSuffix() const { return ""; }
170 
171  int _id;
174 };
175 
176 //------------------------------------------------------------------------------
177 // GmStateDumpFunctionMapDataItem
178 //------------------------------------------------------------------------------
179 
189 {
190 public:
192  const GmLogCategory& logger, QString itemNamePrefix = "");
193 
194  QString translateFunction (void* ptr, bool evaluator);
195  bool updateFunctionList();
196 
197  void resetSaved() { _saved = false; }
198 
199  // See comments on the base class
200  virtual int itemType() const { return GM_FUNCTIONMAP_DUMP_ITEM; }
201 
202  // See comments on the base class
203  virtual bool canCompress() const { return false; }
204 
205  // See comments on the base class
206  virtual bool partialOp() const { return false; }
207 
208  // See comments on the base class
209  virtual bool fixedSize() const { return true; }
210 
211  // See comments on the base class
212  virtual qint64 size() const { assert(!_buffer.isEmpty()); return _buffer.size(); }
213 
214  // See comments on the base class. No need for a header
215  virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
216 
217  virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
218  virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
219  virtual void bufferReleased(int op, bool ok);
220 
221 protected:
222  virtual QString nameSuffix() const;
223 
224 private:
227  bool _saved;
228  int _nuser;
229  int _neval;
233 };
234 
235 //------------------------------------------------------------------------------
236 // GmStateDumpValueSetDataItem
237 //------------------------------------------------------------------------------
238 
287 {
288 public:
290  const GmLogCategory& logger, bool fixed, const GmMesh* mesh, QString itemNamePrefix = "");
291 
292  virtual ~GmStateDumpValueSetDataItem();
293 
299  void resetSaved() { _saved = false; }
300 
301  virtual int itemType() const;
302 
306  int acType() const { return _acType; }
307 
309  const GmMesh* mesh() const { return _mesh; }
310 
311  virtual int itemSize() const;
312 
313  // See comments on the base class
314  virtual bool canCompress() const { return true; }
315 
316  // See comments on the base class
317  virtual bool partialOp() const { return !isDefValueSetData(); }
318 
319  // See comments on the base class
320  virtual bool fixedSize() const { return _fixedHint; }
321 
322  virtual qint64 size() const;
323  virtual bool fillDataHeader(char* header);
324 
325  virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
326  virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
327  virtual void bufferReleased(int op, bool ok);
328 
329 protected:
330  virtual QString nameSuffix() const;
331 
332 private:
333  bool isDefValueSetData() const;
334  void initDefBuffers();
335 
336  GmValueSetData* detach();
337 
339  int _acType;
340  const GmMesh* _mesh;
341  bool _fixedHint;
345  bool _saved;
346  int _loadMode;
347 
349 };
350 
351 //------------------------------------------------------------------------------
352 // GmStateDumpArmaDataItem
353 //------------------------------------------------------------------------------
354 
356 template <class T>
358 {
359 public:
360  GmStateDumpArmaDataItem(int id, T* data, const GmLogCategory& logger, bool fixed, QString itemNamePrefix)
361  : GmStateDumpBaseDataItem(id, itemNamePrefix, logger)
362  {
363  assert(id > 0);
364  assert(data);
365 
366  _data = data;
367  _fixedHint = fixed;
368  }
369 
370  // See comments on the base class
371  virtual int itemSize() const { return sizeof(double); }
372 
373  // See comments on the base class
374  virtual bool canCompress() const { return true; }
375 
376  // See comments on the base class
377  virtual bool partialOp() const { return true; }
378 
379  // See comments on the base class
380  virtual bool fixedSize() const { return _fixedHint; }
381 
382  // See comments on the base class
383  virtual qint64 size() const { return _data->size() * sizeof(double); }
384 
385  // See comments on the base class. No need for a header
386  virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
387 
388  // See comments on the base class
389  virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0)
390  {
391  Q_UNUSED(size);
392  assert(size >= 0 && offset >= 0);
393  assert((unsigned)(size + offset) <= _data->size() * sizeof(double));
394  if(_data->size())
395  bufferList.addBuffer(((char*)_data->memptr()) + offset, size ? size : _data->size() * sizeof(double));
396  }
397 
398  // See comments on the base class
399  virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0)
400  {
401  Q_UNUSED(header);
402  assert(size > 0 && offset >= 0);
403 
404  if((unsigned)(size + offset) > _data->size() * sizeof(double))
405  return false; // No growing of the vector
406  bufferList.addBuffer(((char*)_data->memptr()) + offset, size);
407  return true;
408  }
409 
410 private:
411  T* _data;
412  bool _fixedHint;
413 };
414 
415 //------------------------------------------------------------------------------
416 // GmStateDumpVectorDataItem
417 //------------------------------------------------------------------------------
418 
421 {
422 public:
424  GmStateDumpVectorDataItem(int id, GmVector* vec, const GmLogCategory& logger, bool fixed,
425  QString itemNamePrefix = "")
426  : GmStateDumpArmaDataItem<GmVector>(id, vec, logger, fixed, itemNamePrefix.isEmpty() ? "Vec" : itemNamePrefix) {}
427 
428  // See comments on the base class
429  virtual int itemType() const { return GM_VECTOR_DUMP_ITEM; }
430 };
431 
432 //------------------------------------------------------------------------------
433 // GmStateDumpMatrixDataItem
434 //------------------------------------------------------------------------------
435 
438 {
439 public:
441  GmStateDumpMatrixDataItem(int id, GmMatrix* mat, const GmLogCategory& logger, bool fixed,
442  QString itemNamePrefix = "")
443  : GmStateDumpArmaDataItem<GmMatrix>(id, mat, logger, fixed, itemNamePrefix.isEmpty() ? "Mat" : itemNamePrefix) {}
444 
445  // See comments on the base class
446  virtual int itemType() const { return GM_MATRIX_DUMP_ITEM; }
447 };
448 
449 //------------------------------------------------------------------------------
450 // GmStateDumpBufferDataItem
451 //------------------------------------------------------------------------------
452 
466 {
467 public:
468  GmStateDumpBufferDataItem(int id, char** data, int* size, int sizeMultiplier,
469  bool checkSizes, const GmLogCategory& logger, bool fixed,
470  QString itemNamePrefix = "");
471 
472  GmStateDumpBufferDataItem(int id, char* data, int size, bool checkSizes,
473  const GmLogCategory& logger, bool fixed, QString itemNamePrefix = "");
474 
475  void addBuffer(char** data, int* size, int sizeMultiplier);
476  void addBuffer(char* data, int size);
477 
478  void clearBuffers();
479 
480  // See comments on the base class
481  virtual int itemType() const { return GM_BUFFER_DUMP_ITEM; }
482 
483  // See comments on the base class
484  virtual bool canCompress() const { return true; }
485 
486  // See comments on the base class
487  virtual bool partialOp() const { return false; }
488 
489  // See comments on the base class
490  virtual bool fixedSize() const { return _fixedHint; }
491 
492  // See comments on the base class
493  virtual qint64 size() const { return _totalSize; }
494 
495  virtual bool opStart(int op);
496  virtual bool opEnd (int op);
497 
498  virtual bool fillDataHeader(char* header);
499 
500  virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
501  virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
502 
503 private:
505  class BufferData {
506  void* _data;
507  int* _size;
508  int _fsize;
510  public:
511  BufferData() : _data(NULL), _size(NULL), _multiplier(0) {} // Def constructor needed by QVector
512  BufferData(char** d, int* s, int m) : _data(d), _size(s), _fsize(0), _multiplier(m) {}
513  BufferData(char* d, int s) : _data(d), _size(NULL), _fsize(s), _multiplier(1) {}
514 
516  int bsize() const { return _size ? (*_size) * _multiplier : _fsize; }
517 
519  char* bptr() const { return _size ? *((char**)_data) : (char*)_data; }
520  };
521 
524  qint64 _totalSize;
525  bool _fixedHint;
526  bool _checkSizes;
527 };
528 
529 //------------------------------------------------------------------------------
530 // GmStateDumpSDVectorDataItem
531 //------------------------------------------------------------------------------
532 
541 template <class Vector>
543 {
544 public:
548  GmStateDumpSDVectorDataItem(int id, Vector* data, bool noresize, const GmLogCategory& logger,
549  bool fixed, QString itemNamePrefix = "")
550  : GmStateDumpBaseDataItem(id, itemNamePrefix.isEmpty() ? "SDVector" : itemNamePrefix, logger)
551  {
552  S_TRACE(); assert(id > 0); assert(data);
553  _data = data;
554  _fixedHint = fixed;
555  _noresize = noresize;
556  }
557 
558  // See comments on the base class
559  virtual int itemType() const { return GM_SDVECTOR_DUMP_ITEM; }
560 
561  // See comments on the base class
562  virtual bool canCompress() const { return true; }
563 
564  // See comments on the base class
565  virtual bool partialOp() const { return false; }
566 
567  // See comments on the base class
568  virtual bool fixedSize() const { return _fixedHint; }
569 
570  // See comments on the base class
571  virtual qint64 size() const { return _data->size() * sizeof(Vector::DataType); }
572 
574  virtual bool fillDataHeader(char* header)
575  {
576  S_TRACE();
577  assert(GM_MEMORY_DUMP_ITEM_DATA_SIZE >= 2 * sizeof(qint64));
578 
579  qint64* p = (qint64*)header;
580  p[0] = _data->numDumpBuffers();
581  assert(p[0] > 0 && p[0] <= 2);
582 
583  qint64 b1 = _data->dumpBufferSize(0);
584  qint64 b2 = (p[0] == 2) ? _data->dumpBufferSize(1) : 0;
585  assert(b1 <= std::numeric_limits<qint64>::max() - b2); // No overflow expected when adding b1 & b2
586 
587  p[1] = b1 + b2;
588  return true;
589  }
590 
591  // See comments on the base class
592  virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0)
593  {
594  S_TRACE(); Q_UNUSED(size); Q_UNUSED(offset);
595  assert(size == 0 && offset == 0); // No support for partial save
596 
597  for(int i = 0, n = _data->numDumpBuffers(); i < n; i++)
598  {
599  qint64 s = _data->dumpBufferSize(i);
600  if(s)
601  bufferList.addBuffer(_data->dumpBuffer(i), s);
602  }
603  }
604 
605  // See comments on the base class
606  virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0)
607  {
608  S_TRACE(); Q_UNUSED(header); Q_UNUSED(offset);
609  assert(size > 0 && offset == 0);
610 
611  qint64* p = (qint64*)header;
612  if(size != p[1])
613  return false; // Unexpected buffer size!
614 
615  int items = (int)(size / sizeof(Vector::DataType));
616  assert(items * sizeof(Vector::DataType) == size); // size was a multiple of the item size!
617 
618  if(_data->size() != items)
619  {
620  if(_noresize)
621  return false; // error. Buffers don't have the expected size and noresize was specified!
622  _data->clear();
623  _data->addValues(items);
624  }
625 
626  for(int i = 0, n = _data->numDumpBuffers(); i < n; i++)
627  bufferList.addBuffer(_data->dumpBuffer(i), _data->dumpBufferSize(i));
628  return true;
629  }
630 
631 private:
632  Vector* _data;
633  bool _fixedHint;
634  bool _noresize;
635 };
636 
639 
642 
643 //------------------------------------------------------------------------------
644 // GmStateDumpSplitIntVecDataItem
645 //------------------------------------------------------------------------------
646 
663 {
664 public:
665  GmStateDumpSplitIntVecDataItem(int id, QList<int*>* dataList, QList<int>* sizeList, bool compact,
666  const GmLogCategory& logger, bool fixed, QString itemNamePrefix = "");
667 
668  // See comments on the base class
669  virtual int itemType() const { return GM_SPLITINTVEC_DUMP_ITEM; }
670 
671  // See comments on the base class
672  virtual bool canCompress() const { return true; }
673 
674  // See comments on the base class
675  virtual bool partialOp() const { return false; }
676 
677  // See comments on the base class
678  virtual bool fixedSize() const { return _fixedHint; }
679 
680  // See comments on the base class
681  virtual qint64 size() const { return _totalSize; }
682 
683  virtual bool opStart(int op);
684 
685  virtual bool fillDataHeader(char* header);
686 
687  virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
688  virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
689 
690 private:
691  bool _compact;
694  qint64 _totalSize;
695  bool _fixedHint;
696 };
697 
698 //------------------------------------------------------------------------------
699 // GmStateDumpMapDataItem
700 //------------------------------------------------------------------------------
701 
703 template <class K, class V>
705 {
706 public:
707  GmStateDumpMapDataItem(int id, QMap<K, V>* data, bool fixedHint, const GmLogCategory& logger,
708  QString itemNamePrefix = "");
709 
710  // See comments on the base class
711  virtual int itemType() const { return GM_MAP_DUMP_ITEM; }
712 
713  // See comments on the base class
714  virtual bool canCompress() const { return true; }
715 
716  // See comments on the base class
717  virtual bool partialOp() const { return false; }
718 
719  // See comments on the base class
720  virtual bool fixedSize() const { return _fixedHint; }
721 
722  virtual bool opStart(int op);
723  virtual bool opEnd(int op);
724 
725  // See comments on the base class
726  virtual qint64 size() const { assert(!_data.isEmpty()); return _data.size(); }
727 
728  // See comments on the base class. No need for a header
729  virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
730 
731  virtual void getDataBuffer(GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
732  virtual bool setDataBuffer(GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
733  virtual void bufferReleased(int op, bool ok);
734 
735 protected:
739  virtual bool fillMapData(QMap<K, V>* map) { Q_UNUSED(map); return true; }
740 
745  virtual bool mapDataLoaded(QMap<K, V>* map) { Q_UNUSED(map); return true; }
746 
747 private:
749  bool _fixedHint;
751 };
752 
753 //------------------------------------------------------------------------------
754 // GmStateDumpVariantMapDataItem
755 //------------------------------------------------------------------------------
756 
759 {
760 public:
761  GmStateDumpVariantMapDataItem(int id, QVariantMap* data, bool fixedHint, const GmLogCategory& logger,
762  QString itemNamePrefix = "")
763  : GmStateDumpMapDataItem<QString, QVariant>(id, data, fixedHint, logger,
764  itemNamePrefix.isEmpty() ? "VarMap" : itemNamePrefix) {}
765 };
766 
767 //------------------------------------------------------------------------------
768 // GmStateDumpFileItem
769 //------------------------------------------------------------------------------
770 
797 {
798 public:
799  GmStateDumpFileItem(int id, FILE* fhandle, QString fileName, QString tempName,
800  const GmLogCategory& logger, QString itemNamePrefix = "");
801 
802  // See comments on the base class
803  virtual int itemType() const { return GM_FILE_DUMP_ITEM; }
804 
805 protected:
806  virtual bool fillMapData (QVariantMap* map);
807  virtual bool mapDataLoaded(QVariantMap* map);
808 
809 private:
810  FILE* _fileh;
813  QVariantMap _dataMap;
814 };
815 
816 //------------------------------------------------------------------------------
817 // GmStateDumpLuaDataItem
818 //------------------------------------------------------------------------------
819 
822 {
823 public:
824  GmStateDumpLuaDataItem(int id, lua_State* L, const QStringList& globals,
825  const QStringList& locals, QString localTabName,
826  const GmLogCategory& logger, QString itemNamePrefix = "");
827 
828  // See comments on the base class
829  virtual int itemType() const { return GM_LUA_DUMP_ITEM; }
830 
831  // See comments on the base class
832  virtual bool canCompress() const { return true; }
833 
834  // See comments on the base class
835  virtual bool partialOp() const { return false; }
836 
837  // See comments on the base class
838  virtual bool fixedSize() const { return false; }
839 
840  // See comments on the base class
841  virtual bool opStart(int op) { return op == 0 ? loadDataFromLuaState() : true; }
842 
843  // See comments on the base class
844  virtual qint64 size() const { assert(!_data.isEmpty()); return _data.size(); }
845 
846  // See comments on the base class. No need for a header
847  virtual bool fillDataHeader(char* header) { Q_UNUSED(header); return false; }
848 
849  virtual void getDataBuffer (GmMemoryBufferList& bufferList, qint64 size = 0, qint64 offset = 0);
850  virtual bool setDataBuffer (GmMemoryBufferList& bufferList, const char* header, qint64 size, qint64 offset = 0);
851  virtual void bufferReleased(int op, bool ok);
852 
853 private:
854  bool loadDataFromLuaState();
855  void saveDataToLuaState();
856 
857  lua_State* _L;
862 };
863 
864 #endif
Dump item for Lua global/local variables.
Definition: gmStateDumpItem.h:106
int acType() const
Returns the accessor type received on the object constructor (0 = normal, 1 = normal part of ghost ac...
Definition: gmStateDumpItem.h:306
virtual QString itemName() const
Returns the default item name composed of the object prefix + '_' + the object id,...
Definition: gmStateDumpItem.h:153
Dump item for accessor values.
Definition: gmStateDumpItem.h:100
GmValueAccessor * _ac2
A second accessor object used when working with ghost accessors. Can be NULL.
Definition: gmStateDumpItem.h:226
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:562
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:481
Dump item for a list of int vectors.
Definition: gmStateDumpItem.h:110
QVector< BufferData > _bufferDataList
The stored data + size.
Definition: gmStateDumpItem.h:522
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:838
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:412
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:380
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:829
void addBuffer(char *buffer, qint64 size)
Adds another buffer to the buffer list.
Definition: gmMemoryDump.cpp:207
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:726
Implementation of the GmDualVector and GmDualVectorR template classes.
GmValueAccessor * _ac1
The accessor object providing the stored data.
Definition: gmStateDumpItem.h:225
#define GM_MEMORY_DUMP_ITEM_NAME_SIZE
The maximum size for a dump item name.
Definition: gmMemoryDump.h:46
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:568
GmStateDumpFunctionMapDataItem * _functionMap
The map used to translate function pointers to and from function ids.
Definition: gmStateDumpItem.h:348
void truncate(int position)
virtual bool opEnd(int op)
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryD...
Definition: gmMemoryDump.h:141
QVarLengthArray< char > _buffer
The buffer used by getDataBuffer() / setDataBuffer()
Definition: gmStateDumpItem.h:230
Dump item for "Append only" files.
Definition: gmStateDumpItem.h:107
Dump item for a QMap.
Definition: gmStateDumpItem.h:105
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:695
void * _data
Either a pointer to the buffer pointer (char**) or a pointer to the buffer (char*)
Definition: gmStateDumpItem.h:506
QString _prefix
The object name prefix.
Definition: gmStateDumpItem.h:172
QMap< void *, QString > _userMap
The map translating loaded user function pointers to user function Ids.
Definition: gmStateDumpItem.h:231
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:484
Dump item for GmMatrix values.
Definition: gmStateDumpItem.h:103
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:209
QStringList _locals
The name of the local variables to be saved/loaded.
Definition: gmStateDumpItem.h:859
Class responsible for storing Lua global / local values.
Definition: gmStateDumpItem.h:821
int _acType
Acessor type (0 = normal, 1 = geometry part of ghost ac and 2 = ghost part of ghost ac)
Definition: gmStateDumpItem.h:339
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition: gmStateDump.h:52
Dump item for multiple user buffers.
Definition: gmStateDumpItem.h:104
bool _compact
Is this a compact list? See the class description.
Definition: gmStateDumpItem.h:691
Class responsible for storing either a GmVector / GmMatrix object.
Definition: gmStateDumpItem.h:357
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:389
int _defBufferSize
The size of the def buffers.
Definition: gmStateDumpItem.h:344
int _neval
The number of evaluators on the _getBuffer.
Definition: gmStateDumpItem.h:229
virtual bool opStart(int op)
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryD...
Definition: gmStateDumpItem.h:841
Declaration of the GmMemoryDump and GmMemoryDumpItem classes.
int _multiplier
Multiplier to transform (*_size) into bytes or 1 if _fsize was filled.
Definition: gmStateDumpItem.h:509
Dump item for a GmSingleVector or a GmDualVector.
Definition: gmStateDumpItem.h:111
virtual bool setDataBuffer(GmMemoryBufferList &bufferList, const char *header, qint64 size, qint64 offset=0)=0
Fills the provided bufferList object with the set of buffers that should be used to update the dump i...
QByteArray _data
The serialized data.
Definition: gmStateDumpItem.h:861
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
const GmLogCategory & _logger
Basic logger object for dump messages.
Definition: gmStateDumpItem.h:173
char * _defSetBuffer
The internal buffer used by set operations for default value sets.
Definition: gmStateDumpItem.h:343
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:844
virtual qint64 size() const =0
Returns the current item size (in bytes)
int * _size
Pointer to the buffer size.
Definition: gmStateDumpItem.h:507
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition: gmStateDumpItem.h:215
#define S_TRACE()
Macro for run time stack tracking at release build.
Definition: gmTrace.h:44
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:374
GmStateDumpMatrixDataItem(int id, GmMatrix *mat, const GmLogCategory &logger, bool fixed, QString itemNamePrefix="")
Constructor.
Definition: gmStateDumpItem.h:441
A helper class that can store a list of buffers and their sizes, allowing for GmMemoryDumpItem instan...
Definition: gmMemoryDump.h:58
GmStateDumpBaseDataItem(int id, QString prefix, const GmLogCategory &logger)
Constructor.
Definition: gmStateDumpItem.h:135
#define GM_MEMORY_DUMP_ITEM_DATA_SIZE
The size of the per item fixed item data buffer.
Definition: gmMemoryDump.h:49
lua_State * _L
The Lua state where the values will be loaded/saved.
Definition: gmStateDumpItem.h:857
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition: gmStateDumpItem.h:386
Class responsible for storing the needed data to rollback an "append only" file to a previous state.
Definition: gmStateDumpItem.h:796
QVector< int > _sizes
The current buffer sizes when the operation started.
Definition: gmStateDumpItem.h:523
Declaration of the GmMatrix class.
A GmMemoryDumpItem implementation loading / storing values from the GmValueSetData object associated ...
Definition: gmStateDumpItem.h:286
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:317
qint64 _totalSize
The sum of the sizes in _sizes when the operation started.
Definition: gmStateDumpItem.h:524
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:720
Mask for the high bits defining the basic dump item type.
Definition: gmStateDumpItem.h:115
virtual QString nameSuffix() const
Virtual method returning the extra part of the item name, added to its standard prefix.
Definition: gmStateDumpItem.h:169
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:377
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:672
QByteArray _data
The serialized data.
Definition: gmStateDumpItem.h:750
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:490
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
T * _data
The stored vector / matrix.
Definition: gmStateDumpItem.h:411
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 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:606
Class responsible for storing the contents provided by a list of int vectors, each with its own size,...
Definition: gmStateDumpItem.h:662
Class responsible for storing a GmVector object.
Definition: gmStateDumpItem.h:420
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:206
void resetSaved()
Resets the flag stating whether this item has already been saved or not. This operation is needed if ...
Definition: gmStateDumpItem.h:299
GmTrackedValueAccessor * _ac
The accessor object providing the stored data.
Definition: gmStateDumpItem.h:338
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:571
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:320
virtual void bufferReleased(int op, bool ok)
Function called once after a call to getDataBuffer() / setDataBuffer() to inform the item data that t...
Definition: gmMemoryDump.h:217
Class responsible for storing a QMap of values. Usefull for storing generic sets of "scalar" attribut...
Definition: gmStateDumpItem.h:704
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:717
virtual bool fillDataHeader(char *header)
Fills a header with the number of stored buffers (1 or 2) and their sizes.
Definition: gmStateDumpItem.h:574
QMap< void *, QString > _evalMap
The map translating loaded function evaluator pointers to user function Ids.
Definition: gmStateDumpItem.h:232
int _fsize
A fixed size for _data (in bytes), valid when _size is NULL.
Definition: gmStateDumpItem.h:508
virtual int itemType() const =0
Returns the item type.
QList< int * > * _dataList
The data list.
Definition: gmStateDumpItem.h:692
Class responsible for storing a GmSingleVector or a GmDualVector.
Definition: gmStateDumpItem.h:542
Class responsible for a QVariantMap of values. Usefull for storing generic sets of "scalar" attribute...
Definition: gmStateDumpItem.h:758
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition: gmStateDumpItem.h:729
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:212
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:98
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:487
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:446
bool isEmpty() const const
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:681
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:678
Dump item for mapping function pointers to function names.
Definition: gmStateDumpItem.h:101
int _id
The object id.
Definition: gmStateDumpItem.h:171
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:749
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:525
Dump item for GmVector values.
Definition: gmStateDumpItem.h:102
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:429
Vector * _data
The stored vector (either a GmSingleVector or a GmDualVector)
Definition: gmStateDumpItem.h:632
QString _localTabName
The name of the table used to store local variable values.
Definition: gmStateDumpItem.h:860
Class responsible for storing one or more user buffer objects.
Definition: gmStateDumpItem.h:465
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:200
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:669
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:745
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:203
char * bptr() const
Returns the buffer pointer.
Definition: gmStateDumpItem.h:519
virtual bool opStart(int op)
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryD...
Definition: gmMemoryDump.h:132
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:559
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:711
QString _baseName
The base file name. Should be equal to the same data when restored.
Definition: gmStateDumpItem.h:811
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:399
bool _saved
Has this dump item been saved at least once?
Definition: gmStateDumpItem.h:227
GmStateDumpSDVectorDataItem< GmSingleVector< int > > GmStateDumpSingleVectorIntDataItem
A GmStateDumpSDVectorDataItem for a GmSingleVector<int>
Definition: gmStateDumpItem.h:638
QMap< K, V > * _varMap
The stored map.
Definition: gmStateDumpItem.h:748
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
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:314
qint64 _totalSize
The sum of the sizes in _sizeLists when the operation started.
Definition: gmStateDumpItem.h:694
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:493
QVariantMap _dataMap
The stored variant map.
Definition: gmStateDumpItem.h:813
bool _checkSizes
When restoring, individual buffer sizes should be checked?
Definition: gmStateDumpItem.h:526
Auxiliary class responisble for allowing a value accessor to track changes to the referenced value se...
Definition: gmTrackedValueAccessor.h:37
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base cl...
Definition: gmValueSetData.h:65
virtual ~GmGroupDumpItem()
Virtual destructor.
Definition: gmStateDumpItem.h:56
Helper structure to store a tuple (buffer ptr, size ptr, size multiplier)
Definition: gmStateDumpItem.h:505
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
int _loadMode
-1 = set not called, 0 = data on value set, 1 = data on defSetBuffer is double vec,...
Definition: gmStateDumpItem.h:346
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:565
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:714
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:739
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:675
Implementation of the GmSingleVector template class.
Class responsible for storing a table mapping function pointers (either an user function or a functio...
Definition: gmStateDumpItem.h:188
bool _noresize
States that the buffers should not be automatically reside on a restore.
Definition: gmStateDumpItem.h:634
virtual int itemSize() const
The item size needed for calculating sizes and offsets in bytes for partial updates....
Definition: gmStateDumpItem.h:371
Dump item for Boundary condition objects.
Definition: gmStateDumpItem.h:109
Ensure that all dump items stored by GmStateDump have an id() and a logger.
Definition: gmStateDumpItem.h:131
const GmMesh * mesh() const
Returns the mesh registered by the constructor.
Definition: gmStateDumpItem.h:309
const GmMesh * _mesh
The mesh that this accessor is tied to for acType == 2.
Definition: gmStateDumpItem.h:340
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:341
virtual bool fillDataHeader(char *header)=0
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
virtual bool stateSaved(GmStateDump *state)
Virtual method called just after succesfully completing a save operation on the given state....
Definition: gmStateDumpItem.h:75
bool _saved
Has this dump item been saved at least once?
Definition: gmStateDumpItem.h:345
virtual bool partialOp() const
Does this item supports partial load / save operations?
Definition: gmStateDumpItem.h:835
int _nuser
The number of user function entries on the _getBuffer.
Definition: gmStateDumpItem.h:228
virtual void getDataBuffer(GmMemoryBufferList &bufferList, qint64 size=0, qint64 offset=0)=0
Fills the provided bufferList object with the set of buffers that together define the dump item data.
virtual bool canCompress() const
Should this item be compressed if the MemoryDump object is configured with compression?
Definition: gmStateDumpItem.h:832
virtual int itemSize() const
The item size needed for calculating sizes and offsets in bytes for partial updates....
Definition: gmStateDumpItem.h:147
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
QList< int > * _sizeList
The sizes for each vector in _dataList.
Definition: gmStateDumpItem.h:693
GmStateDumpSDVectorDataItem< GmDualVector< int > > GmStateDumpDualVectorIntDataItem
A GmStateDumpSDVectorDataItem for a GmDualVector<int>
Definition: gmStateDumpItem.h:641
virtual qint64 size() const
Returns the current item size (in bytes)
Definition: gmStateDumpItem.h:383
bool _fixedHint
Does this object has a low probability of growing?
Definition: gmStateDumpItem.h:633
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:548
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition: gmStateDumpItem.h:52
QStringList _globals
The name of the global variables to be saved/loaded.
Definition: gmStateDumpItem.h:858
virtual int itemType() const
Returns the item type.
Definition: gmStateDumpItem.h:803
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
FILE * _fileh
The file handle.
Definition: gmStateDumpItem.h:810
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
Interface for an object that can be dumped and undumped to either file or memory by GmMemoryDump.
Definition: gmMemoryDump.h:99
Dump item for mesh objects.
Definition: gmStateDumpItem.h:108
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
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
QString _fileName
The actual file name for fileh. Might be different from _baseName when working with temp files.
Definition: gmStateDumpItem.h:812
int id()
Returns the internal dump item id.
Definition: gmStateDumpItem.h:144
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:592
GmStateDumpVectorDataItem(int id, GmVector *vec, const GmLogCategory &logger, bool fixed, QString itemNamePrefix="")
Constructor.
Definition: gmStateDumpItem.h:424
char * _defGetBuffer
The internal buffer used by get operations for default value sets.
Definition: gmStateDumpItem.h:342
int bsize() const
Returns the buffer size in bytes.
Definition: gmStateDumpItem.h:516
Class responsible for storing a GmMatrix object.
Definition: gmStateDumpItem.h:437
virtual bool fillDataHeader(char *header)
Function called together with getDataBuffer() to provide a "header information" with fixed size (equa...
Definition: gmStateDumpItem.h:847