sipxmedialib  Version 3.3
Protected Attributes | Friends | List of all members
MpBufPtr Class Reference

Smart pointer to MpBuf. More...

#include <MpBuf.h>

Inheritance diagram for MpBufPtr:
Inheritance graph
[legend]
Collaboration diagram for MpBufPtr:
Collaboration graph
[legend]

Public Member Functions

Creators
 MpBufPtr ()
 Default constructor - construct invalid pointer. More...
 
 MpBufPtr (MpBuf *buffer)
 This constructor owns MpBuf object. More...
 
 ~MpBufPtr ()
 Destructor. It decrements buffer's reference counter. More...
 
 MpBufPtr (const MpBufPtr &buffer)
 Copy buffer pointer and increment its reference counter. More...
 
MpBufPtr clone () const
 
Manipulators
MpBufPtroperator= (const MpBufPtr &bufferPtr)
 Smart assignment. More...
 
bool operator== (const MpBufPtr &pBuffer)
 Compare two smart pointers. More...
 
bool operator!= (const MpBufPtr &pBuffer)
 Compare two smart pointers. More...
 
void release ()
 Release buffer we are pointing to. More...
 
void swap (MpBufPtr &pBuffer)
 Swap to buffers. More...
 
bool requestWrite ()
 Check if buffer is writable and create copy if no. More...
 
Accessors
int getBufferNumber () const
 Return number of the buffer in the pool. Use this for debug output. More...
 
void setFlowGraph (MpFlowGraphBase *flowgraph)
 
MpBufoperator-> ()
 Return pointer to MpBuf. More...
 
const MpBufoperator-> () const
 Return readonly pointer to MpBuf. More...
 
MP_BUFFERS_TREE getType () const
 
Inquiry
bool isValid () const
 Can this pointer be dereferenced? Use this function instead of NULL comparison. More...
 
bool isWritable ()
 You should write to the buffer if and only if this function return true. More...
 

Protected Attributes

MpBufmpBuffer
 Pointer to real buffer. More...
 

Friends

class MpBufPool
 
struct MpDataBuf
 

Detailed Description

Smart pointer to MpBuf.

You should only use this smart pointer, not MpBuf* itself. The goal of this smart pointer is to care about reference counter and buffer deallocation.

Constructor & Destructor Documentation

MpBufPtr ( )
inline

Default constructor - construct invalid pointer.

MpBufPtr ( MpBuf buffer)
inline

This constructor owns MpBuf object.

Note
THIS CONSTRUCTOR ARE ONLY USABLE BY POOLS
~MpBufPtr ( )
inline

Destructor. It decrements buffer's reference counter.

MpBufPtr ( const MpBufPtr buffer)
inline

Copy buffer pointer and increment its reference counter.

Member Function Documentation

MpBufPtr clone ( ) const
inline
MpBufPtr& operator= ( const MpBufPtr bufferPtr)
inline

Smart assignment.

Decrement reference counter of our old buffer and increment in new one.

bool operator== ( const MpBufPtr pBuffer)
inline

Compare two smart pointers.

Two pointers assumed equal if they point to the same buffer.

bool operator!= ( const MpBufPtr pBuffer)
inline

Compare two smart pointers.

Two pointers assumed equal if they point to the same buffer.

void release ( )
inline

Release buffer we are pointing to.

If no one else is pointing to this buffer it will be freed.

void swap ( MpBufPtr pBuffer)
inline

Swap to buffers.

This pointer will point to buffer pointed by pBuffer, and pBuffer will point to buffer, pointed by this pointer. Swap does not modify reference counters of buffers.

bool requestWrite ( )
inline

Check if buffer is writable and create copy if no.

Returns
true - on success.
false - if buffer cannot be made writable. E.g. if buffer contain NULL pointer.
int getBufferNumber ( ) const
inline

Return number of the buffer in the pool. Use this for debug output.

void setFlowGraph ( MpFlowGraphBase flowgraph)
inline
MpBuf* operator-> ( )
inline

Return pointer to MpBuf.

const MpBuf* operator-> ( ) const
inline

Return readonly pointer to MpBuf.

MP_BUFFERS_TREE getType ( ) const
inline
bool isValid ( ) const
inline

Can this pointer be dereferenced? Use this function instead of NULL comparison.

bool isWritable ( )
inline

You should write to the buffer if and only if this function return true.

isWritable() check are you the only owner of this buffer.

Friends And Related Function Documentation

friend class MpBufPool
friend
friend struct MpDataBuf
friend

Member Data Documentation

MpBuf* mpBuffer
protected

Pointer to real buffer.