1 | /* $Id: BandwidthControlImpl.h 62485 2016-07-22 18:36:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VirtualBox COM class implementation
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef ____H_BANDWIDTHCONTROLIMPL
|
---|
20 | #define ____H_BANDWIDTHCONTROLIMPL
|
---|
21 |
|
---|
22 | #include "BandwidthControlWrap.h"
|
---|
23 |
|
---|
24 | class BandwidthGroup;
|
---|
25 |
|
---|
26 | namespace settings
|
---|
27 | {
|
---|
28 | struct IOSettings;
|
---|
29 | }
|
---|
30 |
|
---|
31 | class ATL_NO_VTABLE BandwidthControl :
|
---|
32 | public BandwidthControlWrap
|
---|
33 | {
|
---|
34 | public:
|
---|
35 |
|
---|
36 | DECLARE_EMPTY_CTOR_DTOR(BandwidthControl)
|
---|
37 |
|
---|
38 | HRESULT FinalConstruct();
|
---|
39 | void FinalRelease();
|
---|
40 |
|
---|
41 | // public initializer/uninitializer for internal purposes only
|
---|
42 | HRESULT init(Machine *aParent);
|
---|
43 | HRESULT init(Machine *aParent, BandwidthControl *aThat);
|
---|
44 | HRESULT initCopy(Machine *aParent, BandwidthControl *aThat);
|
---|
45 | void uninit();
|
---|
46 |
|
---|
47 | // public internal methods
|
---|
48 | HRESULT i_loadSettings(const settings::IOSettings &data);
|
---|
49 | HRESULT i_saveSettings(settings::IOSettings &data);
|
---|
50 | void i_rollback();
|
---|
51 | void i_commit();
|
---|
52 | void i_copyFrom(BandwidthControl *aThat);
|
---|
53 | Machine *i_getMachine() const;
|
---|
54 | HRESULT i_getBandwidthGroupByName(const Utf8Str &aName,
|
---|
55 | ComObjPtr<BandwidthGroup> &aBandwidthGroup,
|
---|
56 | bool aSetError /* = false */);
|
---|
57 |
|
---|
58 | private:
|
---|
59 |
|
---|
60 | // wrapped IBandwidthControl properties
|
---|
61 | HRESULT getNumGroups(ULONG *aNumGroups);
|
---|
62 |
|
---|
63 | // wrapped IBandwidthControl methods
|
---|
64 | HRESULT createBandwidthGroup(const com::Utf8Str &aName,
|
---|
65 | BandwidthGroupType_T aType,
|
---|
66 | LONG64 aMaxBytesPerSec);
|
---|
67 | HRESULT deleteBandwidthGroup(const com::Utf8Str &aName);
|
---|
68 | HRESULT getBandwidthGroup(const com::Utf8Str &aName,
|
---|
69 | ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
70 | HRESULT getAllBandwidthGroups(std::vector<ComPtr<IBandwidthGroup> > &aBandwidthGroups);
|
---|
71 |
|
---|
72 | // Data
|
---|
73 | typedef std::list< ComObjPtr<BandwidthGroup> > BandwidthGroupList;
|
---|
74 |
|
---|
75 | struct Data
|
---|
76 | {
|
---|
77 | Data(Machine *pMachine)
|
---|
78 | : pParent(pMachine)
|
---|
79 | { }
|
---|
80 |
|
---|
81 | ~Data()
|
---|
82 | {};
|
---|
83 |
|
---|
84 | Machine * const pParent;
|
---|
85 |
|
---|
86 | // peer machine's bandwidth control
|
---|
87 | const ComObjPtr<BandwidthControl> pPeer;
|
---|
88 |
|
---|
89 | // the following fields need special backup/rollback/commit handling,
|
---|
90 | // so they cannot be a part of BackupableData
|
---|
91 | Backupable<BandwidthGroupList> llBandwidthGroups;
|
---|
92 | };
|
---|
93 |
|
---|
94 | Data *m;
|
---|
95 | };
|
---|
96 |
|
---|
97 | #endif // ____H_BANDWIDTHCONTROLIMPL
|
---|
98 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|