ADTF  3.18.2
memoryblock.h
Go to the documentation of this file.
1 
7 #ifndef __MEMORY_BLOCK_HEADER
8 #define __MEMORY_BLOCK_HEADER
9 
10 namespace A_UTILS_NS
11 {
19 class DOEXPORT cMemoryBlock
20 {
22 
23  public:
27  typedef enum
28  {
30  ML_CURRENT = 0x01,
32  ML_FUTURE = 0x02
33  } tMemoryLockFlags;
34 
35  protected:
38 
39  protected:
43 
44  #ifdef _DEBUG
45  tBool m_bProtectionField;
46  #endif // _DEBUG
47 
48  public:
53 
59 
64  cMemoryBlock(const cMemoryBlock& oBlock);
65 
69  virtual ~cMemoryBlock();
70 
78 
86 
97  tResult Alloc(tSize nSize, tSize nAlignment, tUInt32 ui32Flags = 0);
98 
103 
109  tVoid* GetPtr() const;
110 
116  tSize GetSize() const;
117 
130  tResult Set(const tVoid* src, tSize nByteCount);
131 
140  tResult CopyTo(tVoid* dest) const;
141 
149 
154  operator tVoid*() const;
155 
162  tResult Swap(cMemoryBlock& refMemBlock);
163 
164  public:
165 
172  static tVoid* AllocPageAlignedMemory(tSize nSize, tSize nPageSize = 0);
173 
181 
182  public:
193  static tVoid MemCopy(tVoid* pDest, const tVoid* pSrc, tSize nCount);
194 
203  static tVoid MemZero(tVoid* pDest, tSize nCount);
204 
214  static tVoid MemSet(tVoid* pDest, tInt nValue, tSize nCount);
215 
227  static tInt MemCmp(const tVoid* pMem1, const tVoid* pMem2, tSize nCount);
228 
240  static tResult MemLock(const tVoid* pAddress, tSize nSize);
241 
252  static tResult MemUnlock(const tVoid* pAddress, tSize nSize);
253 
263  static tResult MemLockAll(tUInt32 nFlags);
264 
273 };
274 
275 } // namespace A_UTILS_NS
276 
277 namespace std
278 {
279  //specialization for cMemoryBlock (needed for ADL)
281 }
282 
283 #endif // __MEMORY_BLOCK_HEADER
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
size_t tSize
type definition for a array size values, map size values etc.
Memory block class.
Definition: memoryblock.h:20
static tVoid MemCopy(tVoid *pDest, const tVoid *pSrc, tSize nCount)
Copies data from one buffer to another.
static tResult MemLockAll(tUInt32 nFlags)
Locks the whole virtual address area.
tResult Zero()
Sets all allocated bytes to zero.
static tUInt32 m_ui32Protector
Protector for debugging purposes.
Definition: memoryblock.h:36
static tVoid * AllocPageAlignedMemory(tSize nSize, tSize nPageSize=0)
use
tSize m_nSize
Size of buffer.
Definition: memoryblock.h:42
tResult Alloc(tSize nSize, tSize nAlignment, tUInt32 ui32Flags=0)
Allocates memory at addresses that are a multiple of an alignment value.
tResult Alloc(tSize nSize)
(Re)allocates memory
tResult Set(const tVoid *src, tSize nByteCount)
Copy data and adjust allocated memory size as necessary.
virtual ~cMemoryBlock()
Destructor.
tResult Resize(tSize nSize)
(Re)allocates memory
static tVoid MemZero(tVoid *pDest, tSize nCount)
Sets the data of a buffer to zero.
cMemoryBlock(const cMemoryBlock &oBlock)
Copy constructor.
cMemoryBlock(tSize nSize)
Constructor which preallocates memory.
static tInt MemCmp(const tVoid *pMem1, const tVoid *pMem2, tSize nCount)
Compares the data bytes of two memory buffers.
static tResult MemUnlockAll()
Unlocks all the virtual address areas previously locked by cMemoryBlock::MemLock or cMemoryBlock::Mem...
tVoid * GetPtr() const
Get a pointer to the allocated memory.
tVoid Free()
Frees all allocated memory.
tSize GetSize() const
Get the amount of allocated memory in bytes.
static tResult MemUnlock(const tVoid *pAddress, tSize nSize)
Unlocks part of the virtual address previously locked by cMemoryBlock::MemLock.
static tUInt32 m_ui32DefaultSectorSize
Default sector size.
Definition: memoryblock.h:37
tResult CopyTo(tVoid *dest) const
Copy data from the allocated memory into the provided destination buffer.
static tResult MemLock(const tVoid *pAddress, tSize nSize)
Locks part of the calling process's virtual address space into RAM preventing that memory from being ...
cMemoryBlock()
Default constructor.
tVoid * m_Ptr
Pointer to memory block.
Definition: memoryblock.h:40
tResult Swap(cMemoryBlock &refMemBlock)
Swaps the administrated memory between two memory blocks.
tVoid * m_pBuffer
Internal buffer.
Definition: memoryblock.h:41
static tVoid FreePageAlignedMemory(tVoid *pMemory)
use
static tVoid MemSet(tVoid *pDest, tInt nValue, tSize nCount)
Fills the data bytes of a buffer to the specified value.
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11