Mobile API Reference  MicroStrategy 2019
BufferImplementation.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : SimpleBuffer.h
3 // AUTHOR : ydong
4 // CREATION : 1/28/2013
5 // Copyright (C) MicroStrategy Incorporated 2001
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MBase_SimpleBuffer_h
9 #define MBase_SimpleBuffer_h
10 
11 #include <vector>
12 
13 #include "Base/Base/Buffer.h"
14 
15 
16 namespace MBase
17 {
18  //No Lock, auto release memory when destructure.
20  {
21  public:
22  typedef std::pair<unsigned char*, int> MemBlock;
23  typedef std::vector<MemBlock> MemVec;
24  public:
25 
27  ~BufferImplementation() throw();
28  virtual void Delete() throw();
29 
30  // Allocates a chunk of memory according to the size.
31  // Any further memory request will be allocated from this chunk until the chunk is used up.
32  // return true if success
33  virtual bool Reserve(size_t iSize);
34 
35  // Returns a pointer to the memory (equivalent of doing a new)
36  // throws BufferException if buffer was previously locked
37  // throws ContractManagerException (defined in BaseMemoryContract.h)
38  virtual void* GetMem(size_t iSize);
39 
40  // returns the total memory reserved by the buffer, in KB
41  virtual unsigned Int32 GetTotalMemSize() const ;
42 
43  // returns the total memory reserved AND used by the buffer, in KB
44  virtual unsigned Int32 GetAllocMemSize() const ;
45 
46  //xfan. 4/13/09, TQMS 354241. Add new interface
47  virtual unsigned Int64 GetTotalMemSizeInBytes() const ;
48  virtual unsigned Int64 GetAllocMemSizeInBytes() const ;
49 
50  // Use this function to make the buffer "read-only"
51  // when this function is called the memory contained by the
52  // the buffer gets locked from writes
53  // throws BufferException if unable to lock
54  virtual void WriteLock() ;
55 
56  // set the maxium limit for the total allocated space size, if the size is over the limit,
57  // the buffer.GetMem operation will throw an BufferException
58  // it is currently to be used by SQL Engine only
59  virtual void SetTotalAllocatedSpaceLimit(Int64 iLimit) ;
60 
61 
62  private:
63  MemVec mBuffer;
64  };
65 }
66 
67 #endif // MBase_BufferImplementation_h
Definition: BufferImplementation.h:19
Definition: Buffer.h:58
#define Int64
Definition: BasicTypes.h:36
std::vector< MemBlock > MemVec
Definition: BufferImplementation.h:23
virtual unsigned Int32 GetAllocMemSize() const
virtual bool Reserve(size_t iSize)
virtual unsigned Int64 GetTotalMemSizeInBytes() const
#define Int32
Definition: BasicTypes.h:20
Definition: Allocator.h:47
virtual void SetTotalAllocatedSpaceLimit(Int64 iLimit)
virtual unsigned Int32 GetTotalMemSize() const
virtual void * GetMem(size_t iSize)
std::pair< unsigned char *, int > MemBlock
Definition: BufferImplementation.h:22
virtual unsigned Int64 GetAllocMemSizeInBytes() const