Tezzeret  1
Tezzeret
GmCharRingBufferStorage.hpp
1 #ifndef GM_CHAR_RING_BUFFER_STORAGE_HPP_
2 #define GM_CHAR_RING_BUFFER_STORAGE_HPP_
3 
4 #include <GmCharRingBuffer.hpp>
5 #include <GmStorage.hpp>
6 
7 namespace Geometrics
8 {
9 
11  {
12  public:
13  GmRingBufferFileStorage (void *buffer,
14  uint64_t bufferSize);
15  int Open (int *fileIndex);
16  virtual int Close (int iFileIndex);
17  int Erase (int fileIndex);
18  int64_t FileSize (int fileIndex);
19 
20 
21  GmRingBufferFileStorage () = delete; // No default constructor.
22 
23  // Without this variable defined in a cpp file, the CCS linker won't find a place
24  // for the vtable for this class. Hacky. Maybe find some real functionality
25  // in here.
26  virtual int WriteData (const char* pcData,
27  unsigned int iDataSize,
28  UInt32 ui32Topic);
29  int OpenRead (const int fileIndex);
30  int Read (void *dest,
31  int64_t count);
32 
33  int FileSize (const int fileName,
34  int64_t &fileSize);
35  int GetFileInfoIndex (const int fileName);
36 
37  /***********************************************************************************/
38  /* Some storages need to treat some groups of writes as single transactions. For */
39  /* example, file storages may decide to roll over to a new physical file after */
40  /* some number of writes. In the case of array writes, when the header gets */
41  /* written and then a set of records gets written, the file storage must */
42  /* put the array header and all of the individual records all in the same file, */
43  /* and roll over only after the end. The default behavior for storages */
44  /* is a NOP. EnterTransaction and LeaveTransaction handle this feature. */
45  /***********************************************************************************/
46  virtual int EnterTransaction ();
47  virtual int LeaveTransaction ();
48  virtual int RollAndSynchFile ();
49 
50  //virtual int IsFileStorage () { return FALSE; };
51  virtual int IsDataStorage () { return TRUE; };
52  int CheckToFlush ();
53  int WriteHeader ();
54  int SelectSurveyEx (const char *strSurveyId);
55  int SelectAcqJsonEx (const char *strSurveyId,
56  const char *strAcquisitionId);
57  int SelectAcqEx (const char *strSurveyId,
58  const char *strAcquisitionId);
59  int64_t StartOf (const int fileName);
60  int64_t EndOf (const int fileName);
61 
62 
63  virtual int GetLastError () { return -1; };
64 
66 
67  public:
68  int Initialize ();
69  int SetEmpty ();
70 
71 
72  public:
74  {
75  public:
76  int Initialize();
77  int64_t mSize;
78  int64_t mStart;
79  int64_t mNumber;
80  bool mReadOnly;
81  bool mIsOpen;
82  };
83 
84 #define NUM_BUFFER_FILE_INFOS (10)
85  GmRingBufferFileInfo mFiles[NUM_BUFFER_FILE_INFOS];
86  int mLastFileInfo;
87 
88 
89 
90 
91  GmCharRingBuffer mBuffer;
92  int mLastFileIndex;
93  int mWritesCounted;
94 
95  int mApproximateBytesPerFile;
96  Bool m_bInTransaction;
97  char m_szCurrentActiveSurveyId[MAX_SURVEY_ID_LENGTH+1],
98  m_szCurrentActiveAcquisitionId[MAX_ACQUISITION_ID_LENGTH+1];
99 
100 
101 
102  };
103 
104 }
105 #endif /* GM_CHAR_RING_BUFFER_STORAGE_HPP_ */
Definition: GmCharRingBuffer.hpp:26
Definition: GmCharRingBufferStorage.hpp:74
Definition: GmCharRingBufferStorage.hpp:11
Definition: GmStorage.hpp:81
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47