VirtualBox

Ignore:
Timestamp:
Dec 4, 2009 6:19:05 PM (15 years ago)
Author:
vboxsync
Message:

Main: make MediumAttachment instance data private

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r24989 r25200  
    2525#include "VirtualBoxBase.h"
    2626
    27 #include "MediumImpl.h"
    28 
    2927class Machine;
    3028class Medium;
     
    4846    END_COM_MAP()
    4947
    50     DECLARE_EMPTY_CTOR_DTOR(MediumAttachment)
     48    MediumAttachment() { };
     49    ~MediumAttachment() { };
    5150
    5251    // public initializer/uninitializer for internal purposes only
     
    6362    void FinalRelease();
    6463
    65     bool rollback();
    66     void commit();
    67 
    6864    // IMediumAttachment properties
    6965    STDMETHOD(COMGETTER(Medium))(IMedium **aMedium);
     
    7470    STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
    7571
    76     // unsafe inline public methods for internal purposes only (ensure there is
     72    // public internal methods
     73    bool rollback();
     74    void commit();
     75
     76    // unsafe public methods for internal purposes only (ensure there is
    7777    // a caller and a read lock before calling them!)
     78    bool isImplicit() const;
     79    void setImplicit(bool aImplicit);
    7880
    79     bool isImplicit() const { return m->implicit; }
    80     void setImplicit(bool aImplicit) { m->implicit = aImplicit; }
     81    const ComObjPtr<Medium>& getMedium() const;
     82    Bstr getControllerName() const;
     83    LONG getPort() const;
     84    LONG getDevice() const;
     85    DeviceType_T getType() const;
     86    bool getPassthrough() const;
    8187
    82     const ComObjPtr<Medium>& getMedium() const { return m->medium; }
    83     Bstr getControllerName() const { return m->controllerName; }
    84     LONG getPort() const { return m->port; }
    85     LONG getDevice() const { return m->device; }
    86     DeviceType_T getType() const { return m->type; }
    87     bool getPassthrough() const { AutoReadLock lock(this); return m->passthrough; }
    88 
    89     bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice)
    90     {
    91         return (    aControllerName == m->controllerName
    92                  && aPort == m->port
    93                  && aDevice == m->device);
    94     }
     88    bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice);
    9589
    9690    /** Must be called from under this object's write lock. */
    97     void updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit)
    98     {
    99         m.backup();
    100         m->medium = aMedium;
    101         m->implicit = aImplicit;
    102     }
     91    void updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit);
    10392
    10493    /** Must be called from under this object's write lock. */
    105     void updatePassthrough(bool aPassthrough)
    106     {
    107         m.backup();
    108         m->passthrough = aPassthrough;
    109     }
     94    void updatePassthrough(bool aPassthrough);
    11095
    11196    /** Get a unique and somewhat descriptive name for logging. */
     
    116101
    117102private:
    118 
    119     /** Reference to Machine object, for checking mutable state. */
    120     const ComObjPtr<Machine, ComWeakRef> mParent;
    121     /* later: const ComObjPtr<MediumAttachment> mPeer; */
    122 
    123     struct Data
    124     {
    125         Data() : port(0), device(0), type(DeviceType_Null),
    126                  passthrough(false), implicit(false) {}
    127 
    128         bool operator== (const Data &that) const
    129         {
    130             return   this == &that
    131                    || (passthrough == that.passthrough);
    132         }
    133 
    134         ComObjPtr<Medium> medium;
    135         /* Since MediumAttachment is not a first class citizen when it
    136          * comes to managing settings, having a reference to the storage
    137          * controller will not work - when settings are changed it will point
    138          * to the old, uninitialized instance. Changing this requires
    139          * substantial changes to MediumImpl.cpp. */
    140         const Bstr controllerName;
    141         const LONG port;
    142         const LONG device;
    143         const DeviceType_T type;
    144         bool passthrough : 1;
    145         bool implicit : 1;
    146     };
    147 
    148     Backupable<Data> m;
     103    struct Data;
     104    Data *m;
    149105
    150106    Utf8Str mLogName;                   /**< For logging purposes */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette