sipxmedialib  Version 3.3
MpArrayBuf.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2006 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _INCLUDED_MPARRAYBUF_H // [
12 #define _INCLUDED_MPARRAYBUF_H
13 
14 // SYSTEM INCLUDES
15 // APPLICATION INCLUDES
16 #include "mp/MpBuf.h"
17 
18 // DEFINES
19 // MACROS
20 // EXTERNAL FUNCTIONS
21 // EXTERNAL VARIABLES
22 // CONSTANTS
23 // STRUCTS
24 // TYPEDEFS
25 
27 
33 struct MpArrayBuf : public MpBuf
34 {
35  friend class MpArrayBufPtr;
36 
37 /* //////////////////////////// PUBLIC //////////////////////////////////// */
38 public:
39 
40 /* ============================ CREATORS ================================== */
42 
43 
44 
46 
47 /* ============================ MANIPULATORS ============================== */
49 
50 
52  bool setDataSize( int size
53  );
63 
64 /* ============================ ACCESSORS ================================= */
66 
67 
69  char *getDataWritePtr() {return mpData;}
70 
72  const char *getDataPtr() const {return mpData;}
73 
75  static int getHeaderSize() {
76  static MpArrayBuf* foo = NULL;
77  return (unsigned long)(&foo->mpData[0] - (char*)foo);
78  }
79 
80 
82  unsigned getMaxDataSize() const
83  {return mpPool->getBlockSize()-getHeaderSize();}
84 
86  unsigned getDataSize() const {return mDataSize;}
87 
89 
90 /* ============================ INQUIRY =================================== */
92 
93 
94 
96 
97 /* //////////////////////////// PROTECTED ///////////////////////////////// */
98 protected:
99 
100  unsigned mDataSize;
101  char mpData[1];
102 
104  void init();
105 
106 /* //////////////////////////// PRIVATE /////////////////////////////////// */
107 private:
108 
110  MpArrayBuf(const MpBuf &);
115  MpArrayBuf &operator=(const MpBuf &);
120 };
121 
123 
128 class MpArrayBufPtr : public MpBufPtr {
129 
130 /* //////////////////////////// PUBLIC //////////////////////////////////// */
131 public:
132 
133 /* ============================ CREATORS ================================== */
135 
136 
139 
140 
142 
143 
145 
146 
147 
148 /* ============================ MANIPULATORS ============================== */
150 
151 
153 
154 /* ============================ ACCESSORS ================================= */
156 
157 
160 
161 
163 
164 
165 
166 /* ============================ INQUIRY =================================== */
168 
169 
170 
171 
172 
173 /* //////////////////////////// PROTECTED ///////////////////////////////// */
174 protected:
175 
176 
177 /* //////////////////////////// PRIVATE /////////////////////////////////// */
178 private:
179 
180 };
181 
182 
183 #endif // _INCLUDED_MPARRAYBUF_H ]
#define MPBUF_TYPECHECKED_COPY(classname, buffer_type, base_classname)
Copy object from base type with type check.
Definition: MpBuf.h:407
char mpData[1]
Pointer to the data, following this header.
Definition: MpArrayBuf.h:101
static int getHeaderSize()
Get size of MpArrayBuf without data (in bytes).
Definition: MpArrayBuf.h:75
Begin of the MpArrayBuf type.
Definition: MpBuf.h:47
unsigned getBlockSize() const
Return size of the one block in the pool (in bytes).
Definition: MpBufPool.h:69
unsigned mDataSize
Size of the following data (in bytes).
Definition: MpArrayBuf.h:100
char * getDataWritePtr()
Get pointer to the buffer data with intent to write/change it.
Definition: MpArrayBuf.h:69
MpArrayBuf(const MpBuf &)
Disable copy (and other) constructor.
#define MPBUF_MEMBER_ACCESS_OPERATOR(classname)
Return pointer to buffer.
Definition: MpBuf.h:417
#define MPBUF_CONST_MEMBER_ACCESS_OPERATOR(classname)
Return readonly pointer to buffer.
Definition: MpBuf.h:422
void init()
This is called in place of constructor.
Definition: MpArrayBuf.cpp:51
unsigned getDataSize() const
Get current data size.
Definition: MpArrayBuf.h:86
Smart pointer to MpArrayBuf.
Definition: MpArrayBuf.h:128
const char * getDataPtr() const
Get read only pointer to the buffer data.
Definition: MpArrayBuf.h:72
MpArrayBuf & operator=(const MpBuf &)
Disable assignment operator.
MpBufPool * mpPool
Parent memory pool.
Definition: MpBuf.h:127
Smart pointer to MpBuf.
Definition: MpBuf.h:160
bool setDataSize(int size)
Set current data size.
Definition: MpArrayBuf.cpp:24
Base class for all media buffers.
Definition: MpBuf.h:74
unsigned getMaxDataSize() const
Get maximum allowed payload size (in bytes).
Definition: MpArrayBuf.h:82
Stores data right after the header.
Definition: MpArrayBuf.h:33
#define MPBUF_DEFAULT_CONSTRUCTOR(classname)
Default constructor - construct invalid pointer.
Definition: MpBuf.h:387
#define MPBUF_FROM_BASE_CONSTRUCTOR(classname, buffer_type, base_classname)
This constructor owns MpBuf object.
Definition: MpBuf.h:397