ADTF  3.18.2
cMemoryPtr

Classes

class  cMemoryPtrPrivate
 

Public Member Functions

 cMemoryPtr ()
 Default constructor.
 
 cMemoryPtr (tVoid *pvData, tSize nSize)
 Constructor for presetting the assigned buffer. More...
 
 cMemoryPtr (const cMemoryPtr &oMemObject)
 Copy constructor. More...
 
tBool IsReference ()
 Check whether the object owns its memory or is attached to an external buffer. More...
 
tResult Attach (tVoid *pvData, tSize nSize)
 Attaches the object to an external buffer. More...
 
tResult Attach (const cMemoryPtr &oMemObject)
 Attches the object to an external buffer. More...
 
tResult Detach ()
 Detaches the object from an external buffer. More...
 
virtual ~cMemoryPtr ()
 Destructor.
 
tVoid Free ()
 Frees all allocated memory and detaches from external buffers.
 
tResult Alloc (tSize nDataSize)
 Allocates memory. More...
 
tResult Assign (const tVoid *pvData, tSize nDataSize)
 Copies external data to a newly allocated buffer. More...
 
tResult Assign (const cMemoryPtr &oMemObject)
 Copies external data to a newly allocated buffer. More...
 
tResult CopyTo (tVoid *pvBuffer, tSize nBufferSize)
 Copies data to an external buffer. More...
 
const tVoidGetPtr () const
 Get a pointer to the data. More...
 
tVoidGetWritePtr () const
 Get a pointer to the data. More...
 
tSize GetSize () const
 Get the size of the memory region. More...
 
tUInt Ref ()
 Increase reference counter. More...
 
tUInt Unref ()
 Decrease reference counter. More...
 
tVoid Destroy ()
 Destroys the object and frees all allocated resources.
 
 operator const tVoid * () const
 Returns a pointer to the data. More...
 
tVoidoperator= (const cMemoryPtr &oMemObject)
 Copies data.
 
tBool operator== (tVoid *pvData) const
 Checks whether an object handles a memory region. More...
 

Protected Attributes

tUInt m_nReferenceCounter
 Reference counter.
 
tVoidm_pvData
 Pointer to data.
 
tSize m_nDataSize
 Size of data.
 
tBool m_bReference
 Is reference.
 

Detailed Description

Definition at line 22 of file memoryptr.h.

Constructor & Destructor Documentation

◆ cMemoryPtr() [1/2]

cMemoryPtr ( tVoid pvData,
tSize  nSize 
)
inline

Constructor for presetting the assigned buffer.

The data is copied to a new buffer.

Parameters
pvData[in] The buffer.
nSize[in] The size of the buffer.

Definition at line 63 of file memoryptr.h.

References tFalse.

◆ cMemoryPtr() [2/2]

cMemoryPtr ( const cMemoryPtr oMemObject)
inline

Copy constructor.

Parameters
oMemObject[in] The object to copy from.

Definition at line 79 of file memoryptr.h.

References cMemoryPtr::m_nDataSize, cMemoryPtr::m_pvData, and tFalse.

Member Function Documentation

◆ Alloc()

tResult Alloc ( tSize  nDataSize)
inline

Allocates memory.

Parameters
nDataSize[in] The amount of memory in bytes.
Returns
ERR_NOERROR if successfull.
ERR_INVALID_ARG if datasize is less than 1
ERR_MEMORY if buffer could not be allocated

Definition at line 178 of file memoryptr.h.

References A_UTILS_NS::MEMPTR_WRONG_SIZE_PARAM_MASK, RETURN_ERROR, and RETURN_NOERROR.

◆ Assign() [1/2]

tResult Assign ( const cMemoryPtr oMemObject)
inline

Copies external data to a newly allocated buffer.

Parameters
oMemObject[in] The data to copy.
Returns
ERR_NOERROR if successfull
ERR_POINTER if data pointer of oMemObject is nullptr.
ERR_INVALID_ARG if datasize of oMemObject is less than 1

Definition at line 228 of file memoryptr.h.

References cMemoryPtr::m_nDataSize, and cMemoryPtr::m_pvData.

◆ Assign() [2/2]

tResult Assign ( const tVoid pvData,
tSize  nDataSize 
)
inline

Copies external data to a newly allocated buffer.

Parameters
pvData[in] The data to copy.
nDataSize[in] The size of the data.
Returns
ERR_NOERROR if successfull
ERR_POINTER if pvData is nullptr.
ERR_INVALID_ARG if nDataSize is less than 1

Definition at line 211 of file memoryptr.h.

References cMemoryBlock::MemCopy(), RETURN_IF_FAILED, RETURN_IF_POINTER_NULL, and RETURN_NOERROR.

◆ Attach() [1/2]

tResult Attach ( const cMemoryPtr oMemObject)
inline

Attches the object to an external buffer.

Parameters
oMemObject[in] The external buffer.
Returns
ERR_NOERROR if arguments are ok.
ERR_INVALID_ARG if data of oMemObject is nullptr and datasize of oMemObject is not zero or if data of oMemObject is not nullptr but datasize of oMemObject is zero or less

Definition at line 131 of file memoryptr.h.

References cMemoryPtr::m_nDataSize, and cMemoryPtr::m_pvData.

◆ Attach() [2/2]

tResult Attach ( tVoid pvData,
tSize  nSize 
)
inline

Attaches the object to an external buffer.

Parameters
pvData[in] The buffer.
nSize[in] The size of the buffer.
Returns
ERR_NOERROR if arguments are ok.
ERR_INVALID_ARG if pvData is nullptr or nSize zero or less

Definition at line 108 of file memoryptr.h.

References A_UTILS_NS::MEMPTR_WRONG_SIZE_PARAM_MASK, RETURN_ERROR, RETURN_NOERROR, and tTrue.

◆ CopyTo()

tResult CopyTo ( tVoid pvBuffer,
tSize  nBufferSize 
)
inline

Copies data to an external buffer.

Parameters
pvBuffer[in] The destintion buffer.
nBufferSize[in] The amount of bytes to copy.
Returns
ERR_NOERROR if successfull.
ERR_POINTER if pvBuffer is nullptr
ERR_NOT_INITIALIZED if
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 242 of file memoryptr.h.

References cMemoryBlock::MemCopy(), A_UTILS_NS::MEMPTR_WRONG_SIZE_PARAM_MASK, RETURN_ERROR, RETURN_IF_POINTER_NULL, and RETURN_NOERROR.

◆ Detach()

tResult Detach ( )
inline

Detaches the object from an external buffer.

Returns
Standard Result Code.

Definition at line 140 of file memoryptr.h.

References RETURN_NOERROR.

◆ GetPtr()

const tVoid* GetPtr ( ) const
inline

Get a pointer to the data.

Returns
A pointer to the data.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 267 of file memoryptr.h.

◆ GetSize()

tSize GetSize ( ) const
inline

Get the size of the memory region.

Returns
The size of the memory region.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 287 of file memoryptr.h.

◆ GetWritePtr()

tVoid* GetWritePtr ( ) const
inline

Get a pointer to the data.

Returns
A pointer to the data.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 277 of file memoryptr.h.

◆ IsReference()

tBool IsReference ( )
inline

Check whether the object owns its memory or is attached to an external buffer.

Returns
tTrue if it is attached to an external buffer, otherwise tFalse.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 96 of file memoryptr.h.

◆ operator const tVoid *()

operator const tVoid * ( ) const
inline

Returns a pointer to the data.

This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 338 of file memoryptr.h.

◆ operator==()

tBool operator== ( tVoid pvData) const
inline

Checks whether an object handles a memory region.

Parameters
pvDataThe memory region.
Returns
tTrue if it handles the region, tFalse otherwise.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 359 of file memoryptr.h.

◆ Ref()

tUInt Ref ( )
inline

Increase reference counter.

Returns
The new reference count.

Definition at line 297 of file memoryptr.h.

◆ Unref()

tUInt Unref ( )
inline

Decrease reference counter.

Returns
The new reference count.

Definition at line 306 of file memoryptr.h.