ADTF  v2.14.3
cMemoryPtr Class Reference

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 ()
 Get a pointer to the data. More...
 
tSize GetSize ()
 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 30 of file memoryptr.h.

Constructor & Destructor Documentation

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 71 of file memoryptr.h.

References tFalse.

cMemoryPtr ( const cMemoryPtr oMemObject)
inline

Copy constructor.

Parameters
oMemObject[in] The object to copy from.

Definition at line 87 of file memoryptr.h.

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

Member Function Documentation

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 186 of file memoryptr.h.

References ERR_INVALID_ARG, ERR_MEMORY, RETURN_ERROR, and RETURN_NOERROR.

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 NULL.
ERR_INVALID_ARG if nDataSize is less than 1

Definition at line 219 of file memoryptr.h.

References RETURN_IF_FAILED, RETURN_IF_POINTER_NULL, and RETURN_NOERROR.

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 NULL.
ERR_INVALID_ARG if datasize of oMemObject is less than 1

Definition at line 236 of file memoryptr.h.

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

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 NULL or nSize zero or less

Definition at line 116 of file memoryptr.h.

References ERR_INVALID_ARG, RETURN_ERROR, RETURN_NOERROR, and tTrue.

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 NULL and datasize of oMemObject is not zero or if data of oMemObject is not NULL but datasize of oMemObject is zero or less

Definition at line 139 of file memoryptr.h.

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

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 NULL
ERR_NOT_INITIALISED if
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 250 of file memoryptr.h.

References ERR_INVALID_ARG, ERR_NOT_INITIALISED, RETURN_ERROR, RETURN_IF_POINTER_NULL, and RETURN_NOERROR.

tResult Detach ( )
inline

Detaches the object from an external buffer.

Returns
Standard Result Code.

Definition at line 148 of file memoryptr.h.

References RETURN_NOERROR.

const tVoid* GetPtr ( )
inline

Get a pointer to the data.

Returns
A pointer to the data.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 275 of file memoryptr.h.

tSize GetSize ( )
inline

Get the size of the memory region.

Returns
The size of the memory region.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 285 of file memoryptr.h.

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.
See The ADTF Real-Time Extension.

Definition at line 104 of file memoryptr.h.

operator const tVoid * ( ) const
inline

Returns a pointer to the data.

This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 336 of file memoryptr.h.

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.
See The ADTF Real-Time Extension.

Definition at line 357 of file memoryptr.h.

tUInt Ref ( )
inline

Increase reference counter.

Returns
The new reference count.

Definition at line 295 of file memoryptr.h.

tUInt Unref ( )
inline

Decrease reference counter.

Returns
The new reference count.

Definition at line 304 of file memoryptr.h.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)