NeoPZ
TPZPersistenceManager.h
Go to the documentation of this file.
1 #ifndef PERSISTENCEMANAGER_H
2 #define PERSISTENCEMANAGER_H
3 #include <map> // for map
4 #include <list>
5 #include <ostream> // for operator<<, string
6 #include <memory>
7 #include "TPZRestoredInstance.h"
8 
9 template < class T, int NumExtAlloc>
10 class TPZManVector;
11 class TPZSavable;
12 class TPZGeneralFStream;
13 template<class T>
17 class TPZStream;
18 
20  enum streamType { binary = 1, ascii = 2 };
21 };
22 
23 using namespace TPZPersistenceManagerNS;
24 
25 //TODO: Implement CloseRead()
27 
29 
30  protected:
32 
33  // for READING from file
37  static unsigned int mNextMainObjIndex;
38  static std::list<std::map < std::string, uint64_t>> mVersionHistory;
39 
40  // for WRITING to file
41  static std::map<std::string, uint64_t> mFileVersionInfo;
44 public:
46  static std::map<const TPZSavable *, int64_t> mObjMap;
47  static int64_t mNextPointerToSave;
48  // WRITE-RELATED METHODS
49  public:
50  static void OpenWrite(const std::string &fileName, streamType = binary);
51  static void WriteToFile(const TPZSavable *);
52  static void CloseWrite();
53  static int64_t ScheduleToWrite(const TPZSavable *obj);
54  static void WritePointer(const TPZSavable *obj, TPZStream *stream);
55 
56  // READ-RELATED METHODS
57  public:
58  static unsigned int OpenRead(const std::string &fileName, streamType = binary);
59  static void TranslateNextPointer(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion);
60  static void TranslatePointers(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion);
61  static int64_t NewChunkInTranslation();
62  static void SetChunk(const int64_t &objId, TPZAutoPointer<TPZChunkInTranslation> chunk);
63  static TPZRestoredInstance *NewRestoredInstance();
64  static TPZSavable *ReadFromFile();
65  static TPZSavable *GetInstance(const int64_t &objId);
66  static TPZSavable *GetInstance(TPZStream *stream);
67  static TPZAutoPointer<TPZSavable> GetAutoPointer(const int64_t &objId);
68  static std::shared_ptr<TPZSavable> GetSharedPointer(const int64_t &objId);
69  static TPZAutoPointer<TPZSavable> GetAutoPointer(TPZStream *stream);
70  static std::shared_ptr<TPZSavable> GetSharedPointer(TPZStream *stream);
71  static void CloseRead();
72  protected:
73  static void AddInstanceToVec(TPZSavable *, const int &id);
74 
75 };
76 
77 #endif // PERSISTENCEMANAGER_H
static std::list< std::map< std::string, uint64_t > > mVersionHistory
Class for creating a bidirectional circular buffer.
static std::map< const TPZSavable *, int64_t > mObjMap
static TPZVec< const TPZSavable * > mPointersToSave
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
static int64_t mNextPointerToSave
static TPZVec< TPZAutoPointer< TPZChunkInTranslation > > mChunksVec
static TPZGeneralFStream * mpStream
static unsigned int mNextMainObjIndex
static TPZContBufferedStream mCurrentObjectStream
static std::map< std::string, uint64_t > mFileVersionInfo
static TPZVec< int64_t > mMainObjIds
static TPZContBufferedStream mObjectsStream
static TPZVec< TPZRestoredInstance > mObjVec
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
obj
Definition: test.py:225
This class implements a reference counter mechanism to administer a dynamically allocated object...