libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moBuckets.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moBuckets.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29  Class:
30  moBuckets
31 
32  Description:
33  Bucket's class, accumulation buffer
34 
35 
36 *******************************************************************************/
37 
38 #ifndef __MO_BUCKETS_H
39 #define __MO_BUCKETS_H
40 
41 #include "moTypes.h"
42 #include "moLock.h"
43 
44 #define MAX_BUCKETS 2
45 
47 
54 
55  public:
56  moBucket();
57  virtual ~moBucket();
58 
60 
65  bool Lock();
66 
68 
73  bool Unlock();
74 
76 
79  MOubyte *GetBuffer();//gets the bucket's buffer pointer
80 
82 
85  MOlong GetSize();
86 
88 
93  void SetBuffer( MOlong size , MOubyte *pbuf);
94 
96 
100  void Copy( MOlong size , MOubyte *pbuf );//copy size bytes from the bucket's buffer to pbuf
101 
103 
106  void AttachBucket( moBucket* pbucket );
107 
109 
112  moBucket* GetAttachedBucket();//get the bucket's linked bucked
113 
115 
118  void EmptyBucket();//free the bucket's buffer
119 
121 
125  void BuildBucket( MOlong size , int setvalue );
126 
127 
128  protected:
130 
132  bool m_bEmpty;
133 
137 
140 
141 };
142 
143 //SPECIAL FOR NO LOOSING DATA.....
144 
145 
147 
152 class LIBMOLDEO_API moBucketsPool {//Last In Last Out
153 
154  public:
155  moBucketsPool();
156  virtual ~moBucketsPool();
157 
158  bool AddBucket( moBucket *pBucket );//add a created bucket to the pool
159  bool AddBucket( MOlong size , MOubyte *pbuf );//take an empty created bucket and fill it with pbuf
160  moBucket* GetEmptyBucket();//get an empty bucket to fill it
161  moBucket* RetreiveBucket();//retreive from the pool the filled bucket to go
162  moBucket* GetActualBucket();//gets from the pool the pointer to the filled bucket to go, but do not retreive it!!! so beware
163  moBucket* RetreivedBucket();//get the pointer to the retreived bucket
164  bool DestroyRetreivedBucket();//deletes the retreivedbucket...
165  bool IsEmpty();
166  bool IsFull();
167 
169 
170  protected:
172 
173 
174  MOlong m_lMaxBuckets;//60MB = 60 buckets
175  moLock m_PoolLock;//lock access to pool
178 
182 
183 };
184 
185 /*
186 //SPECIAL FOR LIVE DATA.....
187 class LIBMOLDEO_API moBucketsStack {//Last In First Out
188 
189  public:
190  moBucketsStack();
191  ~moBucketsStack();
192 
193  void AddBucket( moBucket *pBucket );
194  moBucket *RetreiveBucket();
195 
196  protected:
197  moBucket *m_pFirstBucketToGo;
198  moBucket *m_pLastBucketToGo;
199 
200 };
201 
202 //SPECIAL FOR SCRATCH VIDEOS OR STREAMING.....
203 class LIBMOLDEO_API moBucketsBuffer {//arbitrary access
204 
205  public:
206  moBucketsBuffer();
207  ~moBucketsBuffer();
208 
209  Cyclic();
210 
211  void AddBucket( moBucket *pBucket );
212  moBucket *RetreiveBucket();
213 
214  protected:
215  moBucket *m_pFirstBucketToGo;
216  moBucket *m_pLastBucketToGo;
217 
218 };
219 */
220 
221 #endif
222 
moBucket * m_pLastEmptyBucket
Definition: moBuckets.h:180
Definition: moLock.h:50
moBucket * m_pFirstEmptyBucket
Definition: moBuckets.h:179
moBucket * m_pAttachedBucketDown
moBucket enlazado para downstreaming
Definition: moBuckets.h:139
MOlong m_nEmptyBuckets
Definition: moBuckets.h:181
moBucket * m_pFirstBucketToGo
Definition: moBuckets.h:176
moBucket * m_pLastBucketToGo
Definition: moBuckets.h:177
MOubyte * m_pBuffer
puntero al espacio en memoria
Definition: moBuckets.h:135
MOlong m_lBufferSize
tamaño del espacio en memoria (buffer)
Definition: moBuckets.h:129
MOlong m_lMaxBuckets
Definition: moBuckets.h:174
#define LIBMOLDEO_API
Definition: moTypes.h:180
#define MOlong
Definition: moTypes.h:391
moBucket * m_pRetreivedBucket
Definition: moBuckets.h:171
bool m_bAlligned
alineación de la memoria, siempre debe estar alineada
Definition: moBuckets.h:131
Administrador de moBucket 's.
Definition: moBuckets.h:152
bool m_bEmpty
indicador si el buffer está vacío o lleno (con datos)
Definition: moBuckets.h:132
moBucket * m_pAttachedBucket
moBucket enlazado
Definition: moBuckets.h:136
moLock m_PoolLock
Definition: moBuckets.h:175
Espacio en memoria para compartir datos entre objetos.
Definition: moBuckets.h:53
moBucket * m_pAttachedBucketUp
moBucket enlazado para upstreaming
Definition: moBuckets.h:138
MOlong m_nBuckets
Definition: moBuckets.h:168
#define MOubyte
Definition: moTypes.h:399
moLock m_Lock
semáforo para el acceso asincrónico
Definition: moBuckets.h:134