Tezzeret  1
Tezzeret
GmMemoryStorage.hpp
1 #ifndef GM_MEMORY_STORAGE_HPP_
2 #define GM_MEMORY_STORAGE_HPP_
3 
4 //#if GEO_MEMORY_STORAGE == GEO_TRUE
5 
6 typedef unsigned long DWORD;
7 
8 #include <geotypes.hpp>
9 #include <GmStorage.hpp>
10 
11 namespace Geometrics
12 {
13  class GmMemoryStorage : public GmStorage
14  {
15  public:
16 
17  GmMemoryStorage (void *buffer, const uint32_t bufferLength);
18  // virtual int Open (const char* zName,
19  // const char* szReadWrite) { return 0; };
20  virtual int Close (int iFileIndex); // { return 0;};
21 
22  // Without this variable defined in a cpp file, the CCS linker won't find a place
23  // for the vtable for this class. Hacky. Maybe find some real functionality
24  // in here.
25  virtual int WriteData (const char* pcData,
26  unsigned int iDataSize,
27  UInt32 ui32Topic);
28 
29  /***********************************************************************************/
30  /* Some storages need to treat some groups of writes as single transactions. For */
31  /* example, file storages may decide to roll over to a new physical file after */
32  /* some number of writes. In the case of array writes, when the header gets */
33  /* written and then a set of records gets written, the file storage must */
34  /* put the array header and all of the individual records all in the same file, */
35  /* and roll over only after the end. The default behavior for storages */
36  /* is a NOP. EnterTransaction and LeaveTransaction handle this feature. */
37  /***********************************************************************************/
38  virtual int EnterTransaction () { return GM_STORAGE_OK; };
39  virtual int LeaveTransaction () { return GM_STORAGE_OK; };
40  virtual int RollAndSynchFile () { return GM_STORAGE_OK; };
41 
42  //virtual int IsFileStorage () { return FALSE; };
43  virtual int IsDataStorage () { return FALSE; };
44 
45 
46 
47  virtual int GetLastError () { return -1; };
48 
49  virtual ~GmMemoryStorage ();
50 
51  /*******************************************************************************************/
52  /* IsOpen is declared here, and also defined, in order to provide a model of the function */
53  /* throughout the class tree derived from GmStorage. BUT, we don't want to rely on this */
54  /* implementation, so it will break. If you develop code that requires IsOpen(), then */
55  /* you must develop for the correction semantics for that class. */
56  /*******************************************************************************************/
57  virtual bool IsOpen () { return m_bIsOpen; /* m_bIsOpen;*/ };
58 
59  protected:
60  bool m_bIsOpen;
61 
62  void Reset ();
63 
64  uint32_t GetWriteCursorLocation() { return mBufferWriteCursor; }
65 
66  private:
67  void *mBuffer;
68  uint32_t mBufferWriteCursor;
69  uint32_t mBufferReadCursor;
70  uint32_t mBufferSize;
71  };
72 }
73 #endif
74 
75 //#endif
Definition: GmMemoryStorage.hpp:14
Definition: GmStorage.hpp:81
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47