|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Network buffer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IRNETWORKBUFFER_H |
|
20 #define IRNETWORKBUFFER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 //========================================class declaration CIRNetworkBuffer============================================ |
|
25 |
|
26 /** |
|
27 * This class is wrapper class which can hold an address of a memory chunk |
|
28 * and size (granularity) of memory chunk. |
|
29 * This is implemented so as to use with queue like TSglQue |
|
30 * iLink is public member and is of a member of type TSglQueLink |
|
31 * The memory address is of TUint8* type and address is of type TInt |
|
32 * you can assign the address and granularity only when you create an instance |
|
33 * and retrive address and size using Des() and GetSize() respectively |
|
34 * typical usage is as follows |
|
35 * Note: This class DOESN'T take any responsibility of removing memory chunk |
|
36 * associated to it when you delete the chunk, since it is not creating the memory |
|
37 * chunk it doesn't do deallocation it has to taken care from where you create |
|
38 * the memory chunk |
|
39 * |
|
40 * Since it may require changes we are not using irbuffercontainer.cpp present in IRMediaEngine |
|
41 * however the logic is borrowed from IRMediaEngine |
|
42 * @code |
|
43 * |
|
44 * TSglQue<CIRNetworkBuffer> Myque; |
|
45 * TInt f_off = _FOFF(CIRNetworkBuffer,iLink); |
|
46 * Myque.SetOffset(f_off); |
|
47 * TUint8* buffer; |
|
48 * TInt sizeofbuffer; |
|
49 * CIRNetworkBuffer* bufferholder; |
|
50 * bufferholder = CIRNetworkBuffer::NewL(buffer,sizeofbuffer); |
|
51 * Myque.AddLast(*bufferholder); |
|
52 * TUint8* ptr = bufferholder->Des(); |
|
53 * TInt size = bufferholder->GetSize(); |
|
54 * bufferholder = Myque.First(); |
|
55 * Myque.Remove(*bufferholder); |
|
56 * delete bufferholder; //deleting bufferholder doesn't deletes memory allocated |
|
57 * //to buffer is not getting deleted we have delete it explicitly |
|
58 * |
|
59 * delete buffer; |
|
60 * |
|
61 * @endcode |
|
62 * |
|
63 */ |
|
64 |
|
65 NONSHARABLE_CLASS( CIRNetworkBuffer ) : public CBase |
|
66 { |
|
67 //member functions |
|
68 public : |
|
69 |
|
70 /** |
|
71 * Two Phase NewL |
|
72 * returns an instance CIRNetworkBuffer |
|
73 * Owned by CIRNetworkBuffer |
|
74 * @param aAddress Address of data chunk |
|
75 * @param aSize Size of data chunk |
|
76 * @return instance CIRNetworkBuffer |
|
77 */ |
|
78 static CIRNetworkBuffer* NewL( TUint8* aAddress,TInt aSize ); |
|
79 |
|
80 /** |
|
81 * Two Phase NewLC |
|
82 * Creates an instance CIRNetworkBuffer |
|
83 * Owned by CIRNetworkBuffer |
|
84 * @param aAddress Address of data chunk |
|
85 * @param aSize Size of data chunk |
|
86 * @return instance CIRNetworkBuffer |
|
87 */ |
|
88 static CIRNetworkBuffer* NewLC( TUint8* aAddress,TInt aSize ); |
|
89 |
|
90 /** |
|
91 * destructor function |
|
92 * Owned by CIRNetworkBuffer |
|
93 */ |
|
94 ~CIRNetworkBuffer(); |
|
95 |
|
96 /** |
|
97 * Des returns the Address of the chunk; |
|
98 * Owned by CIRNetworkBuffer Class |
|
99 * @return address |
|
100 */ |
|
101 TUint8* Des() const; |
|
102 |
|
103 |
|
104 /** |
|
105 * Size returns the size of the chunk; |
|
106 * Owned by CIRNetworkBuffer Class |
|
107 * @return size of chunk |
|
108 */ |
|
109 TInt Size() const; |
|
110 |
|
111 private: |
|
112 |
|
113 /** |
|
114 * Function : CIRNetworkBuffer |
|
115 * default constructor |
|
116 */ |
|
117 CIRNetworkBuffer(); |
|
118 |
|
119 /** |
|
120 * Two Phase ConstructL |
|
121 * Owned by CIRNetworkBuffer |
|
122 * @param aAddress Address of data chunk |
|
123 * @param aSize Size of data chunk |
|
124 */ |
|
125 void ConstructL( TUint8* aAddress,TInt aSize ); |
|
126 |
|
127 public: |
|
128 /** |
|
129 * Queue Link owned by CIRNetworkBuffer |
|
130 */ |
|
131 TSglQueLink iLink; |
|
132 |
|
133 private: |
|
134 |
|
135 /** |
|
136 * Queued buffer pointer owned by CIRNetworkBuffer |
|
137 */ |
|
138 TUint8* iDataAddress; |
|
139 |
|
140 /** |
|
141 * Size of the chunk |
|
142 */ |
|
143 TInt iSize; |
|
144 }; |
|
145 |
|
146 #include "irnetworkbuffer.inl" |
|
147 |
|
148 #endif //IRNETWORKBUFFER_H |
|
149 |
|
150 |