summaryrefslogtreecommitdiff
path: root/src/VBox/Main/include/MediumAttachmentImpl.h
blob: 1f3f3d3b837255646be28d97e4e9aca1aa51ca61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/** @file
 *
 * VirtualBox COM class implementation
 */

/*
 * Copyright (C) 2006-2013 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef ____H_MEDIUMATTACHMENTIMPL
#define ____H_MEDIUMATTACHMENTIMPL

#include "VirtualBoxBase.h"
#include "BandwidthGroupImpl.h"

class ATL_NO_VTABLE MediumAttachment :
    public VirtualBoxBase,
    VBOX_SCRIPTABLE_IMPL(IMediumAttachment)
{
public:
    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumAttachment, IMediumAttachment)

    DECLARE_NOT_AGGREGATABLE(MediumAttachment)

    DECLARE_PROTECT_FINAL_CONSTRUCT()

    BEGIN_COM_MAP(MediumAttachment)
        VBOX_DEFAULT_INTERFACE_ENTRIES(IMediumAttachment)
    END_COM_MAP()

    MediumAttachment() { };
    ~MediumAttachment() { };

    // public initializer/uninitializer for internal purposes only
    HRESULT init(Machine *aParent,
                 Medium *aMedium,
                 const Bstr &aControllerName,
                 LONG aPort,
                 LONG aDevice,
                 DeviceType_T aType,
                 bool fImplicit,
                 bool fPassthrough,
                 bool fTempEject,
                 bool fNonRotational,
                 bool fDiscard,
                 bool fHotPluggable,
                 const Utf8Str &strBandwidthGroup);
    HRESULT initCopy(Machine *aParent, MediumAttachment *aThat);
    void uninit();

    HRESULT FinalConstruct();
    void FinalRelease();

    // IMediumAttachment properties
    STDMETHOD(COMGETTER(Medium))(IMedium **aMedium);
    STDMETHOD(COMGETTER(Controller))(BSTR *aController);
    STDMETHOD(COMGETTER(Port))(LONG *aPort);
    STDMETHOD(COMGETTER(Device))(LONG *aDevice);
    STDMETHOD(COMGETTER(Type))(DeviceType_T *aType);
    STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
    STDMETHOD(COMGETTER(TemporaryEject))(BOOL *aTemporaryEject);
    STDMETHOD(COMGETTER(IsEjected))(BOOL *aIsEjected);
    STDMETHOD(COMGETTER(NonRotational))(BOOL *aNonRotational);
    STDMETHOD(COMGETTER(Discard))(BOOL *aDiscard);
    STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
    STDMETHOD(COMGETTER(HotPluggable))(BOOL *aHotPluggable);

    // public internal methods
    void rollback();
    void commit();

    // unsafe public methods for internal purposes only (ensure there is
    // a caller and a read lock before calling them!)
    bool isImplicit() const;
    void setImplicit(bool aImplicit);

    const ComObjPtr<Medium>& getMedium() const;
    Bstr getControllerName() const;
    LONG getPort() const;
    LONG getDevice() const;
    DeviceType_T getType() const;
    bool getPassthrough() const;
    bool getTempEject() const;
    bool getNonRotational() const;
    bool getDiscard() const;
    const Utf8Str& getBandwidthGroup() const;
    bool getHotPluggable() const;

    bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice);

    /** Must be called from under this object's write lock. */
    void updateMedium(const ComObjPtr<Medium> &aMedium);

    /** Must be called from under this object's write lock. */
    void updatePassthrough(bool aPassthrough);

    /** Must be called from under this object's write lock. */
    void updateTempEject(bool aTempEject);

    /** Must be called from under this object's write lock. */
    void updateNonRotational(bool aNonRotational);

    /** Must be called from under this object's write lock. */
    void updateDiscard(bool aDiscard);

    /** Must be called from under this object's write lock. */
    void updateEjected();

    /** Must be called from under this object's write lock. */
    void updateBandwidthGroup(const Utf8Str &aBandwidthGroup);

    void updateParentMachine(Machine * const pMachine);

    /** Must be called from under this object's write lock. */
    void updateHotPluggable(bool aHotPluggable);

    /** Get a unique and somewhat descriptive name for logging. */
    const char* getLogName(void) const { return mLogName.c_str(); }

private:
    struct Data;
    Data *m;

    Utf8Str mLogName;                   /**< For logging purposes */
};

#endif // ____H_MEDIUMATTACHMENTIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */