VirtualBox

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

Last change on this file since 87093 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • 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 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2018-2020 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#ifndef MAIN_INCLUDED_DataStreamImpl_h
19#define MAIN_INCLUDED_DataStreamImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "DataStreamWrap.h"
25
26#include <iprt/circbuf.h>
27#include <iprt/semaphore.h>
28
29class ATL_NO_VTABLE DataStream
30 : public DataStreamWrap
31{
32public:
33 DECLARE_EMPTY_CTOR_DTOR(DataStream)
34
35 HRESULT FinalConstruct();
36 void FinalRelease();
37
38 HRESULT init(unsigned long aBufferSize);
39 void uninit();
40
41 /// Feed data into the stream, used by the stream source.
42 /// Blocks if the internal buffer cannot take anything, otherwise
43 /// as much as the internal buffer can hold is taken (if smaller
44 /// than @a cbWrite). Modeled after RTStrmWriteEx.
45 int i_write(const void *pvBuf, size_t cbWrite, size_t *pcbWritten);
46
47 /// Marks the end of the stream.
48 int i_close();
49
50private:
51 // wrapped IDataStream attributes and methods
52 HRESULT getReadSize(ULONG *aReadSize);
53 HRESULT read(ULONG aSize, ULONG aTimeoutMS, std::vector<BYTE> &aData);
54
55private:
56 /** The temporary buffer the conversion process writes into and the user reads from. */
57 PRTCIRCBUF m_pBuffer;
58 /** Event semaphore for waiting until data is available. */
59 RTSEMEVENT m_hSemEvtDataAvail;
60 /** Event semaphore for waiting until there is room in the buffer for writing. */
61 RTSEMEVENT m_hSemEvtBufSpcAvail;
62 /** Flag whether the end of stream flag is set. */
63 bool m_fEos;
64};
65
66#endif /* !MAIN_INCLUDED_DataStreamImpl_h */
67
68/* 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