1 | /* $Id: BandwidthControlImpl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VirtualBox COM class implementation
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox base platform packages, as
|
---|
11 | * available from https://www.virtualbox.org.
|
---|
12 | *
|
---|
13 | * This program is free software; you can redistribute it and/or
|
---|
14 | * modify it under the terms of the GNU General Public License
|
---|
15 | * as published by the Free Software Foundation, in version 3 of the
|
---|
16 | * License.
|
---|
17 | *
|
---|
18 | * This program is distributed in the hope that it will be useful, but
|
---|
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | * General Public License for more details.
|
---|
22 | *
|
---|
23 | * You should have received a copy of the GNU General Public License
|
---|
24 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | *
|
---|
26 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef MAIN_INCLUDED_BandwidthControlImpl_h
|
---|
30 | #define MAIN_INCLUDED_BandwidthControlImpl_h
|
---|
31 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
32 | # pragma once
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include "BandwidthControlWrap.h"
|
---|
36 |
|
---|
37 | class BandwidthGroup;
|
---|
38 |
|
---|
39 | namespace settings
|
---|
40 | {
|
---|
41 | struct IOSettings;
|
---|
42 | }
|
---|
43 |
|
---|
44 | class ATL_NO_VTABLE BandwidthControl :
|
---|
45 | public BandwidthControlWrap
|
---|
46 | {
|
---|
47 | public:
|
---|
48 |
|
---|
49 | DECLARE_COMMON_CLASS_METHODS(BandwidthControl)
|
---|
50 |
|
---|
51 | HRESULT FinalConstruct();
|
---|
52 | void FinalRelease();
|
---|
53 |
|
---|
54 | // public initializer/uninitializer for internal purposes only
|
---|
55 | HRESULT init(Machine *aParent);
|
---|
56 | HRESULT init(Machine *aParent, BandwidthControl *aThat);
|
---|
57 | HRESULT initCopy(Machine *aParent, BandwidthControl *aThat);
|
---|
58 | void uninit();
|
---|
59 |
|
---|
60 | // public internal methods
|
---|
61 | HRESULT i_loadSettings(const settings::IOSettings &data);
|
---|
62 | HRESULT i_saveSettings(settings::IOSettings &data);
|
---|
63 | void i_rollback();
|
---|
64 | void i_commit();
|
---|
65 | void i_copyFrom(BandwidthControl *aThat);
|
---|
66 | Machine *i_getMachine() const;
|
---|
67 | HRESULT i_getBandwidthGroupByName(const Utf8Str &aName,
|
---|
68 | ComObjPtr<BandwidthGroup> &aBandwidthGroup,
|
---|
69 | bool aSetError /* = false */);
|
---|
70 |
|
---|
71 | private:
|
---|
72 |
|
---|
73 | // wrapped IBandwidthControl properties
|
---|
74 | HRESULT getNumGroups(ULONG *aNumGroups);
|
---|
75 |
|
---|
76 | // wrapped IBandwidthControl methods
|
---|
77 | HRESULT createBandwidthGroup(const com::Utf8Str &aName,
|
---|
78 | BandwidthGroupType_T aType,
|
---|
79 | LONG64 aMaxBytesPerSec);
|
---|
80 | HRESULT deleteBandwidthGroup(const com::Utf8Str &aName);
|
---|
81 | HRESULT getBandwidthGroup(const com::Utf8Str &aName,
|
---|
82 | ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
83 | HRESULT getAllBandwidthGroups(std::vector<ComPtr<IBandwidthGroup> > &aBandwidthGroups);
|
---|
84 |
|
---|
85 | // Data
|
---|
86 | typedef std::list< ComObjPtr<BandwidthGroup> > BandwidthGroupList;
|
---|
87 |
|
---|
88 | struct Data
|
---|
89 | {
|
---|
90 | Data(Machine *pMachine)
|
---|
91 | : pParent(pMachine)
|
---|
92 | { }
|
---|
93 |
|
---|
94 | ~Data()
|
---|
95 | {};
|
---|
96 |
|
---|
97 | Machine * const pParent;
|
---|
98 |
|
---|
99 | // peer machine's bandwidth control
|
---|
100 | const ComObjPtr<BandwidthControl> pPeer;
|
---|
101 |
|
---|
102 | // the following fields need special backup/rollback/commit handling,
|
---|
103 | // so they cannot be a part of BackupableData
|
---|
104 | Backupable<BandwidthGroupList> llBandwidthGroups;
|
---|
105 | };
|
---|
106 |
|
---|
107 | Data *m;
|
---|
108 | };
|
---|
109 |
|
---|
110 | #endif /* !MAIN_INCLUDED_BandwidthControlImpl_h */
|
---|
111 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|