1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 ____H_BANDWIDTHGROUPIMPL
|
---|
19 | #define ____H_BANDWIDTHGROUPIMPL
|
---|
20 |
|
---|
21 | #include "BandwidthControlImpl.h"
|
---|
22 | #include "BandwidthGroupWrap.h"
|
---|
23 |
|
---|
24 |
|
---|
25 | class ATL_NO_VTABLE BandwidthGroup :
|
---|
26 | public BandwidthGroupWrap
|
---|
27 | {
|
---|
28 | public:
|
---|
29 |
|
---|
30 | DECLARE_EMPTY_CTOR_DTOR(BandwidthGroup)
|
---|
31 |
|
---|
32 | HRESULT FinalConstruct();
|
---|
33 | void FinalRelease();
|
---|
34 |
|
---|
35 | // public initializer/uninitializer for internal purposes only
|
---|
36 | HRESULT init(BandwidthControl *aParent,
|
---|
37 | const Utf8Str &aName,
|
---|
38 | BandwidthGroupType_T aType,
|
---|
39 | LONG64 aMaxBytesPerSec);
|
---|
40 | HRESULT init(BandwidthControl *aParent, BandwidthGroup *aThat, bool aReshare = false);
|
---|
41 | HRESULT initCopy(BandwidthControl *aParent, BandwidthGroup *aThat);
|
---|
42 | void uninit();
|
---|
43 |
|
---|
44 | // public methods only for internal purposes
|
---|
45 | void i_rollback();
|
---|
46 | void i_commit();
|
---|
47 | void i_unshare();
|
---|
48 | void i_reference();
|
---|
49 | void i_release();
|
---|
50 |
|
---|
51 | ComObjPtr<BandwidthGroup> i_getPeer() { return m->pPeer; }
|
---|
52 | const Utf8Str &i_getName() const { return m->bd->strName; }
|
---|
53 | BandwidthGroupType_T i_getType() const { return m->bd->enmType; }
|
---|
54 | LONG64 i_getMaxBytesPerSec() const { return m->bd->aMaxBytesPerSec; }
|
---|
55 | ULONG i_getReferences() const { return m->bd->cReferences; }
|
---|
56 |
|
---|
57 | private:
|
---|
58 |
|
---|
59 | // wrapped IBandwidthGroup properties
|
---|
60 | HRESULT getName(com::Utf8Str &aName);
|
---|
61 | HRESULT getType(BandwidthGroupType_T *aType);
|
---|
62 | HRESULT getReference(ULONG *aReferences);
|
---|
63 | HRESULT getMaxBytesPerSec(LONG64 *aMaxBytesPerSec);
|
---|
64 | HRESULT setMaxBytesPerSec(LONG64 MaxBytesPerSec);
|
---|
65 |
|
---|
66 | ////////////////////////////////////////////////////////////////////////////////
|
---|
67 | ////
|
---|
68 | //// private member data definition
|
---|
69 | ////
|
---|
70 | //////////////////////////////////////////////////////////////////////////////////
|
---|
71 | //
|
---|
72 | struct BackupableBandwidthGroupData
|
---|
73 | {
|
---|
74 | BackupableBandwidthGroupData()
|
---|
75 | : enmType(BandwidthGroupType_Null),
|
---|
76 | aMaxBytesPerSec(0),
|
---|
77 | cReferences(0)
|
---|
78 | { }
|
---|
79 |
|
---|
80 | Utf8Str strName;
|
---|
81 | BandwidthGroupType_T enmType;
|
---|
82 | LONG64 aMaxBytesPerSec;
|
---|
83 | ULONG cReferences;
|
---|
84 | };
|
---|
85 |
|
---|
86 | struct Data
|
---|
87 | {
|
---|
88 | Data(BandwidthControl * const aBandwidthControl)
|
---|
89 | : pParent(aBandwidthControl),
|
---|
90 | pPeer(NULL)
|
---|
91 | { }
|
---|
92 |
|
---|
93 | BandwidthControl * const pParent;
|
---|
94 | ComObjPtr<BandwidthGroup> pPeer;
|
---|
95 |
|
---|
96 | // use the XML settings structure in the members for simplicity
|
---|
97 | Backupable<BackupableBandwidthGroupData> bd;
|
---|
98 | };
|
---|
99 |
|
---|
100 | Data *m;
|
---|
101 | };
|
---|
102 |
|
---|
103 | #endif // ____H_BANDWIDTHGROUPIMPL
|
---|
104 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|