7 #ifndef _MEMORY_PTR_HEADER_
8 #define _MEMORY_PTR_HEADER_
52 m_nReferenceCounter = 1;
67 m_nReferenceCounter = 1;
72 Assign(pvData, nSize);
83 m_nReferenceCounter = 1;
111 if ((
nullptr == pvData)
117 m_bReference =
tTrue;
162 if (!m_bReference && m_pvData !=
nullptr)
164 delete[] (
tUInt*) m_pvData;
180 if ((nDataSize > 0) && (nDataSize <= m_nDataSize))
192 m_pvData =
new (std::nothrow)
tUInt8[nDataSize];
193 if (m_pvData ==
nullptr)
198 m_nDataSize = nDataSize;
246 if ((nBufferSize == 0) ||
247 (nBufferSize > m_nDataSize) ||
252 if (m_pvData ==
nullptr)
299 return ++m_nReferenceCounter;
308 if (m_nReferenceCounter > 0)
310 m_nReferenceCounter--;
313 tUInt nResult = m_nReferenceCounter;
315 if (m_nReferenceCounter == 0)
361 return (m_pvData == pvData);
uint8_t tUInt8
type definition for unsigned integer values (8bit) (platform and compiler independent type).
unsigned int tUInt
type definition for unsigned integer value (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
size_t tSize
type definition for a array size values, map size values etc.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
#define RETURN_IF_POINTER_NULL(_ptr)
Return ERR_POINTER if _ptr is nullptr, which requires the calling function's return type to be tResul...
static tVoid MemCopy(tVoid *pDest, const tVoid *pSrc, tSize nCount)
Copies data from one buffer to another.
tVoid * m_pvData
Pointer to data.
cMemoryPtr(tVoid *pvData, tSize nSize)
Constructor for presetting the assigned buffer.
cMemoryPtr()
Default constructor.
tVoid * GetWritePtr() const
Get a pointer to the data.
const tVoid * GetPtr() const
Get a pointer to the data.
tResult Detach()
Detaches the object from an external buffer.
tUInt m_nReferenceCounter
Reference counter.
tResult Assign(const cMemoryPtr &oMemObject)
Copies external data to a newly allocated buffer.
tResult CopyTo(tVoid *pvBuffer, tSize nBufferSize)
Copies data to an external buffer.
virtual ~cMemoryPtr()
Destructor.
tSize m_nDataSize
Size of data.
tResult Assign(const tVoid *pvData, tSize nDataSize)
Copies external data to a newly allocated buffer.
tResult Attach(const cMemoryPtr &oMemObject)
Attches the object to an external buffer.
tVoid Free()
Frees all allocated memory and detaches from external buffers.
tSize GetSize() const
Get the size of the memory region.
tUInt Ref()
Increase reference counter.
tVoid Destroy()
Destroys the object and frees all allocated resources.
tBool IsReference()
Check whether the object owns its memory or is attached to an external buffer.
tBool m_bReference
Is reference.
tUInt Unref()
Decrease reference counter.
cMemoryPtr(const cMemoryPtr &oMemObject)
Copy constructor.
tResult Attach(tVoid *pvData, tSize nSize)
Attaches the object to an external buffer.
tResult Alloc(tSize nDataSize)
Allocates memory.
A common result class usable as return value throughout.
Template to implement the Private class of the global d_pointer definitions.
#define tFalse
Value for tBool.
#define tTrue
Value for tBool.
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
const tSize MEMPTR_WRONG_SIZE_PARAM_MASK
Memory utility class.
tBool operator==(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.