VirtualBox

source: vbox/trunk/src/VBox/Main/include/DataStreamImpl.h@ 75488

Last change on this file since 75488 was 74822, checked in by vboxsync, 6 years ago

Main: bugref:9152 Implement the convertToStream API

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1/* $Id: DataStreamImpl.h 74822 2018-10-12 18:40:09Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19#ifndef ____H_DATASTREAMIMPL
20#define ____H_DATASTREAMIMPL
21
22#include "DataStreamWrap.h"
23
24#include <iprt/circbuf.h>
25#include <iprt/semaphore.h>
26
27class ATL_NO_VTABLE DataStream
28 : public DataStreamWrap
29{
30public:
31 DECLARE_EMPTY_CTOR_DTOR(DataStream)
32
33 HRESULT FinalConstruct();
34 void FinalRelease();
35
36 HRESULT init(unsigned long aBufferSize);
37 void uninit();
38
39 /// Feed data into the stream, used by the stream source.
40 /// Blocks if the internal buffer cannot take anything, otherwise
41 /// as much as the internal buffer can hold is taken (if smaller
42 /// than @a cbWrite). Modeled after RTStrmWriteEx.
43 int i_write(const void *pvBuf, size_t cbWrite, size_t *pcbWritten);
44
45 /// Marks the end of the stream.
46 int i_close();
47
48private:
49 // wrapped IDataStream attributes and methods
50 HRESULT getReadSize(ULONG *aReadSize);
51 HRESULT read(ULONG aSize, ULONG aTimeoutMS, std::vector<BYTE> &aData);
52
53private:
54 /** The temporary buffer the conversion process writes into and the user reads from. */
55 PRTCIRCBUF m_pBuffer;
56 /** Event semaphore for waiting until data is available. */
57 RTSEMEVENT m_hSemEvtDataAvail;
58 /** Event semaphore for waiting until there is room in the buffer for writing. */
59 RTSEMEVENT m_hSemEvtBufSpcAvail;
60 /** Flag whether the end of stream flag is set. */
61 bool m_fEos;
62};
63
64#endif // !____H_DATASTREAMIMPL
65
66/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette