1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/compapis/RCS/arqapi.h $
4 // $Date: 1997/09/18 13:04:50 $
17 ///////////////////////////////////////////////////////////////////////////////
19 struct IStream
; typedef struct IStream IStream
;
21 F_DECLARE_INTERFACE(IAsyncReadQueue
);
22 F_DECLARE_INTERFACE(IAsyncReadControl
);
23 F_DECLARE_INTERFACE(IAsyncReadFulfiller
);
24 F_DECLARE_INTERFACE(IAsyncStreamer
);
26 typedef struct sARQResult sARQResult
;
27 typedef struct sARQRequest sARQRequest
;
28 typedef struct sARQStreamerDesc sARQStreamerDesc
;
29 typedef struct sARQStreamRequest sARQStreamRequest
;
31 ///////////////////////////////////////////////////////////////////////////////
33 // Asynchronous Read Queue API
37 // Create an asynchronous read queue and add it to the global app-object
39 #define AsyncReadQueueCreate() \
41 IUnknown * pAppUnknown = AppGetObj(IUnknown); \
42 _AsyncReadQueueCreate(IID_TO_REFIID(IID_IAsyncReadQueue), NULL, pAppUnknown); \
43 COMRelease(pAppUnknown); \
48 // Creates an asynchronous read queue, aggregating it with specfied pOuter,
49 // use IAggregate protocol if ppAsyncReadQueue is NULL, else self-init
51 EXTERN tResult LGAPI
_AsyncReadQueueCreate(REFIID
, IAsyncReadQueue
** ppAsyncReadQueue
, IUnknown
* pOuter
);
54 ///////////////////////////////////////////////////////////////////////////////
56 // Read request structures
59 ///////////////////////////////////////
61 // STRUCT: sARQRequest
66 // Pointer to object used to execute read
67 IAsyncReadFulfiller
* pFulfiller
;
69 // Queue to use, zero-based
75 // Optional, client defined data values
78 // Optional tracing name for debug routines
79 const char * pszTrace
;
84 ///////////////////////////////////////
86 // STRUCT: sARQStreamRequest
89 struct sARQStreamRequest
94 // Starting offset, may be kARQCurPos
97 // Length of read, may be kARQToEOF
100 // Queue to use, zero-based
106 // Flags composed of bits from eARQStreamRequestFlags
109 // Destination, may be NULL if dynamic allocation is desired
115 // Optional tracing name for debug routines
116 const char * pszTrace
;
121 #define ARQInitStreamReq(arqreq, src, off, len, que, pri, f, p, sz, nm); \
123 arqreq.pSource = src; \
124 arqreq.offset = off; \
125 arqreq.length = len; \
126 arqreq.queue = que; \
127 arqreq.priority = pri; \
129 arqreq.pBufOut = p; \
130 arqreq.bufSize = sz; \
131 arqreq.pszTrace = nm; \
135 ///////////////////////////////////////
137 #define kARQCurPos (-1L)
138 #define kARQToEOF (-1L)
141 ///////////////////////////////////////
143 enum eARQStreamRequestFlags
145 // Specified buffer may safely be realloced
146 kARQDynamicBuf
= 0x01
150 ///////////////////////////////////////////////////////////////////////////////
152 // STRUCT: sARQResult
157 // Status of the result
160 // Result, whether dynamically allocated or buffer supplied
163 // Size of the result
166 // Flags, composed of bits from eARQResultFlags
169 // Number of read, if streaming 0 if starting, 'frame number' on
176 ///////////////////////////////////////
180 // The buffer was malloc’ed by read queue system
183 // The request is associated with streaming data
186 // The request was killed
192 ///////////////////////////////////////////////////////////////////////////////
194 // STRUCT: sARQStreamerDesc
197 struct sARQStreamerDesc
202 // Starting offset, may be kARQCurPos
208 // Queue to use, zero-based
214 // Flags composed of bits from eAsyncStreamerFlags
217 // Destination of header read, if lenHeader specified.
218 // May be NULL if dynamic allocation is desired
224 // Optional tracing name for debug routines
225 const char * pszTrace
;
231 #define ARQInitStrDesc(strdsc, src, off, len, que, pri, f, p, sz, nm); \
233 strdsc.pSource = src; \
234 strdsc.offsetStart = off; \
235 strdsc.lenHeader = len; \
236 strdsc.queue = que; \
237 strdsc.priority = pri; \
239 strdsc.pBufOut = p; \
240 strdsc.bufSize = sz; \
241 strdsc.pszTrace = nm; \
245 ///////////////////////////////////////
247 enum eAsyncStreamerFlags
249 // The stream should preempt all others in the same queue, for its lifetime
250 kAsStrExclusive
= 0x01
255 ///////////////////////////////////////////////////////////////////////////////
257 // INTERFACE: IAsyncReadQueue
261 #define INTERFACE IAsyncReadQueue
263 DECLARE_INTERFACE_(IAsyncReadQueue
, IUnknown
)
268 DECLARE_UNKNOWN_PURE();
271 // Add a simple request to queue
273 STDMETHOD (QueueRequest
)(THIS_
const sARQRequest
* pRequest
,
274 IAsyncReadControl
** ppControl
) PURE
;
277 // Add a simple stream-oriented request to queue
279 STDMETHOD (QueueStreamRequest
)(THIS_
const sARQStreamRequest
* pRequest
,
280 IAsyncReadControl
** ppControl
) PURE
;
283 // Get a reader for streaming
285 STDMETHOD (GetAsyncStreamer
)(THIS_
const sARQStreamerDesc
* pDesc
,
286 IAsyncStreamer
** ppAsyncStreamer
) PURE
;
291 STDMETHOD (Suspend
)(THIS
) PURE
;
296 STDMETHOD (Resume
)(THIS
) PURE
;
299 // Query if a streamer is blocking
301 STDMETHOD_(BOOL
, IsStreamerBlocking
)(THIS
) PURE
;
304 // Synchronously satisfy all pending requests -- analogous to flush
306 STDMETHOD (FulfillAll
)(THIS
) PURE
;
309 // Synchronously satisfy all pending requests with priority equal to or
310 // higher than the specified priority
312 STDMETHOD (FulfillToPriority
)(THIS_
int priority
) PURE
;
315 // Kill all pending requests
317 STDMETHOD (KillAll
)(THIS
) PURE
;
322 // @TBD (toml 11-12-96): need to finish coding up all these C access macros!
323 #define IAsyncReadQueue_QueryInterface(p, a, b) COMQueryInterface(p, a, b)
324 #define IAsyncReadQueue_AddRef(p) COMAddRef(p)
325 #define IAsyncReadQueue_Release(p) COMRelease(p)
326 #define IAsyncReadQueue_QueueRequest(p, a, b) COMCall2(p, QueueRequest, a, b)
327 #define IAsyncReadQueue_FulfillAll(p) COMCall0(p, FulfillAll)
329 ///////////////////////////////////////////////////////////////////////////////
331 // INTERFACE: IAsyncReadFulfiller
335 #define INTERFACE IAsyncReadFulfiller
337 DECLARE_INTERFACE_(IAsyncReadFulfiller
, IUnknown
)
342 DECLARE_UNKNOWN_PURE();
345 // Satisfy the request
347 STDMETHOD (DoFulfill
)(THIS_
const sARQRequest
*, sARQResult
*) PURE
;
350 // Kill the request, discard if paritally or wholly fulfilled
352 STDMETHOD (DoKill
)(THIS_
const sARQRequest
*, BOOL fDiscard
) PURE
;
357 ///////////////////////////////////////////////////////////////////////////////
359 // INTERFACE: IAsyncReadControl
363 #define INTERFACE IAsyncReadControl
365 DECLARE_INTERFACE_(IAsyncReadControl
, IUnknown
)
370 DECLARE_UNKNOWN_PURE();
373 // Query if request has been fulfilled
375 STDMETHOD_(BOOL
, IsFulfilled
)(THIS
) PURE
;
378 // Synchronously satisfy the request
380 STDMETHOD (Fulfill
)(THIS
) PURE
;
383 // Kill the request, discard if paritally or wholly fulfilled
385 STDMETHOD (Kill
)(THIS_ BOOL fDiscard
) PURE
;
390 STDMETHOD (GetResult
)(THIS_ sARQResult
*) PURE
;
395 ///////////////////////////////////////////////////////////////////////////////
397 // INTERFACE: IAsyncStreamer
401 #define INTERFACE IAsyncStreamer
403 DECLARE_INTERFACE_(IAsyncStreamer
, IUnknown
)
408 DECLARE_UNKNOWN_PURE();
413 STDMETHOD (Read
)(THIS_
void * pBufOut
, long length
) PURE
;
418 STDMETHOD (GetNextResult
)(THIS_ sARQResult
*) PURE
;
421 // Synchronously satisfy all pending requests from this stream -- analogous
424 STDMETHOD (FulfillAll
)(THIS
) PURE
;
427 // Kill all pending requests from this stream
429 STDMETHOD (KillAll
)(THIS_ BOOL fDiscard
) PURE
;
434 ///////////////////////////////////////////////////////////////////////////////
438 #endif /* !__ARQAPI_H */