VirtualBox

Changeset 25194 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Dec 4, 2009 3:59:34 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
55674
Message:

Main: stop USBController from being a VirtualBoxBaseWithChildren; make its instance data private

Location:
trunk/src/VBox/Main/include
Files:
2 edited

Legend:

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

    r24989 r25194  
    4848
    4949class ATL_NO_VTABLE USBController :
    50     public VirtualBoxBaseWithChildrenNEXT,
     50    public VirtualBoxBase,
    5151    public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>,
    5252    public VirtualBoxSupportTranslation<USBController>,
    5353    VBOX_SCRIPTABLE_IMPL(IUSBController)
    5454{
    55 private:
    56 
    57     struct Data
    58     {
    59         /* Constructor. */
    60         Data() : mEnabled (FALSE), mEnabledEhci (FALSE) { }
    61 
    62         bool operator== (const Data &that) const
    63         {
    64             return this == &that || (mEnabled == that.mEnabled && mEnabledEhci == that.mEnabledEhci);
    65         }
    66 
    67         /** Enabled indicator. */
    68         BOOL mEnabled;
    69 
    70         /** Enabled indicator for EHCI. */
    71         BOOL mEnabledEhci;
    72     };
    73 
    7455public:
    75 
    7656    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
    7757
     
    133113    // public methods for internal purposes only
    134114    // (ensure there is a caller and a read lock before calling them!)
    135 
    136     /** @note this doesn't require a read lock since mParent is constant. */
    137     const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; };
    138 
    139     const Backupable<Data>& getData() { return mData; }
     115    Machine* getMachine();
    140116
    141117    // for VirtualBoxSupportErrorInfoImpl
     
    144120private:
    145121
    146 #ifdef VBOX_WITH_USB
    147     /** specialization for IUSBDeviceFilter */
    148     ComObjPtr<USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
    149     {
    150         VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT::
    151                                 getDependentChild (ComPtr<IUnknown> (aFilter));
    152         return child ? static_cast <USBDeviceFilter *> (child)
    153                      : NULL;
    154     }
    155 #endif /* VBOX_WITH_USB */
    156 
    157122    void printList();
    158123
    159     /** Parent object. */
    160     const ComObjPtr<Machine, ComWeakRef> mParent;
    161     /** Peer object. */
    162     const ComObjPtr<USBController> mPeer;
    163     /** Data. */
    164     Backupable<Data> mData;
    165 
    166 #ifdef VBOX_WITH_USB
    167     // the following fields need special backup/rollback/commit handling,
    168     // so they cannot be a part of Data
    169 
    170     typedef std::list <ComObjPtr<USBDeviceFilter> > DeviceFilterList;
    171     Backupable <DeviceFilterList> mDeviceFilters;
    172 #endif /* VBOX_WITH_USB */
     124    struct Data;
     125    Data *m;
    173126};
    174127
  • trunk/src/VBox/Main/include/objectslist.h

    r25184 r25194  
    6767    }
    6868
     69private:
     70    // prohibit copying and assignment
     71    ObjectsList(const ObjectsList &d);
     72    ObjectsList& operator=(const ObjectsList &d);
     73
     74public:
     75
    6976    /**
    7077     * Returns the lock handle which protects this list, for use with
     
    113120            m_ll.push_back(*it);
    114121        }
    115     }
    116 
    117     /**
    118      * Returns the no. of objects on the list (std::list compatibility)
    119      * with locking.
    120      */
    121     size_t size()
    122     {
    123         AutoReadLock al(m_lock);
    124         return m_ll.size();
    125     }
    126 
    127     /**
    128      * Returns the first object on the list (std::list compatibility)
    129      * with locking.
    130      */
    131     MyType front()
    132     {
    133         AutoReadLock al(m_lock);
    134         return m_ll.front();
    135     }
    136 
    137     /**
    138      * Returns a raw pointer to the member list of objects.
    139      * Does not lock!
    140      * @return
    141      */
    142     MyList& getList()
    143     {
    144         return m_ll;
    145     }
    146 
    147     /**
    148      * Returns the begin iterator from the list (std::list compatibility).
    149      * Does not lock!
    150      * @return
    151      */
    152     iterator begin()
    153     {
    154         return m_ll.begin();
    155     }
    156 
    157     /**
    158      * Returns the end iterator from the list (std::list compatibility).
    159      * Does not lock!
    160      */
    161     iterator end()
    162     {
    163         return m_ll.end();
    164122    }
    165123
     
    181139    }
    182140
     141    /**
     142     * Returns the no. of objects on the list (std::list compatibility)
     143     * with locking.
     144     */
     145    size_t size()
     146    {
     147        AutoReadLock al(m_lock);
     148        return m_ll.size();
     149    }
     150
     151    /**
     152     * Returns a raw pointer to the member list of objects.
     153     * Does not lock!
     154     * @return
     155     */
     156    MyList& getList()
     157    {
     158        return m_ll;
     159    }
     160
     161    /**
     162     * Returns the first object on the list (std::list compatibility)
     163     * with locking.
     164     */
     165    MyType front()
     166    {
     167        AutoReadLock al(m_lock);
     168        return m_ll.front();
     169    }
     170
     171    /**
     172     * Returns the begin iterator from the list (std::list compatibility).
     173     * Does not lock!
     174     * @return
     175     */
     176    iterator begin()
     177    {
     178        return m_ll.begin();
     179    }
     180
     181    /**
     182     * Returns the end iterator from the list (std::list compatibility).
     183     * Does not lock!
     184     */
     185    iterator end()
     186    {
     187        return m_ll.end();
     188    }
     189
     190    void insert(iterator it, MyType &p)
     191    {
     192        m_ll.insert(it, p);
     193    }
     194
     195    void erase(iterator it)
     196    {
     197        m_ll.erase(it);
     198    }
     199
    183200private:
    184201    MyList          m_ll;
Note: See TracChangeset for help on using the changeset viewer.

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