VirtualBox

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

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

Main/include: Slapped #pragma once on all headers in prep for GCC precompiled headers. Won't catch repeat includes of an already precompiled header otherwise, i.e. killing most of the PCH gain.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: DataStreamImpl.h 76487 2018-12-27 03:31:39Z 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#ifndef RT_WITHOUT_PRAGMA_ONCE
22# pragma once
23#endif
24
25#include "DataStreamWrap.h"
26
27#include <iprt/circbuf.h>
28#include <iprt/semaphore.h>
29
30class ATL_NO_VTABLE DataStream
31 : public DataStreamWrap
32{
33public:
34 DECLARE_EMPTY_CTOR_DTOR(DataStream)
35
36 HRESULT FinalConstruct();
37 void FinalRelease();
38
39 HRESULT init(unsigned long aBufferSize);
40 void uninit();
41
42 /// Feed data into the stream, used by the stream source.
43 /// Blocks if the internal buffer cannot take anything, otherwise
44 /// as much as the internal buffer can hold is taken (if smaller
45 /// than @a cbWrite). Modeled after RTStrmWriteEx.
46 int i_write(const void *pvBuf, size_t cbWrite, size_t *pcbWritten);
47
48 /// Marks the end of the stream.
49 int i_close();
50
51private:
52 // wrapped IDataStream attributes and methods
53 HRESULT getReadSize(ULONG *aReadSize);
54 HRESULT read(ULONG aSize, ULONG aTimeoutMS, std::vector<BYTE> &aData);
55
56private:
57 /** The temporary buffer the conversion process writes into and the user reads from. */
58 PRTCIRCBUF m_pBuffer;
59 /** Event semaphore for waiting until data is available. */
60 RTSEMEVENT m_hSemEvtDataAvail;
61 /** Event semaphore for waiting until there is room in the buffer for writing. */
62 RTSEMEVENT m_hSemEvtBufSpcAvail;
63 /** Flag whether the end of stream flag is set. */
64 bool m_fEos;
65};
66
67#endif // !____H_DATASTREAMIMPL
68
69/* 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