VirtualBox

Changeset 37068 in vbox for trunk/include/VBox/com


Ignore:
Timestamp:
May 13, 2011 12:38:28 PM (14 years ago)
Author:
vboxsync
Message:

Main: add support for Com(Obj)Ptr<IFACE> in our RTC(MT)List classes

Location:
trunk/include/VBox/com
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/list.h

    r36659 r37068  
    2828#define ___VBox_com_list_h
    2929
     30#include <VBox/com/ptr.h>
    3031#include <VBox/com/string.h>
    3132#include <iprt/cpp/list.h>
     33
     34/**
     35 * Specialized list class for using with com::ComPtr<C>
     36 *
     37 * @note: This is necessary cause ComPtr<IFACE> has a size of 8.
     38 */
     39template <typename C>
     40class RTCList< ComPtr<C> >: public RTCListBase< ComPtr<C>, ComPtr<C>*, false>
     41{
     42    /* Traits */
     43    typedef ComPtr<C>                 T;
     44    typedef T                        *ITYPE;
     45    static const bool                 MT = false;
     46    typedef RTCListBase<T, ITYPE, MT> BASE;
     47
     48public:
     49    /**
     50     * Creates a new list.
     51     *
     52     * This preallocates @a cCapacity elements within the list.
     53     *
     54     * @param   cCapacitiy   The initial capacity the list has.
     55     * @throws  std::bad_alloc
     56     */
     57    RTCList(size_t cCapacity = BASE::DefaultCapacity)
     58     : BASE(cCapacity) {}
     59
     60    /* Define our own new and delete. */
     61    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     62};
     63
     64/**
     65 * Specialized list class for using with com::ComObjPtr<C>
     66 *
     67 * @note: This is necessary cause ComObjPtr<IFACE> has a size of 8.
     68 */
     69template <typename C>
     70class RTCList< ComObjPtr<C> >: public RTCListBase< ComObjPtr<C>, ComObjPtr<C>*, false>
     71{
     72    /* Traits */
     73    typedef ComObjPtr<C>              T;
     74    typedef T                        *ITYPE;
     75    static const bool                 MT = false;
     76    typedef RTCListBase<T, ITYPE, MT> BASE;
     77
     78public:
     79    /**
     80     * Creates a new list.
     81     *
     82     * This preallocates @a cCapacity elements within the list.
     83     *
     84     * @param   cCapacitiy   The initial capacity the list has.
     85     * @throws  std::bad_alloc
     86     */
     87    RTCList(size_t cCapacity = BASE::DefaultCapacity)
     88     : BASE(cCapacity) {}
     89
     90    /* Define our own new and delete. */
     91    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     92};
    3293
    3394/**
  • trunk/include/VBox/com/mtlist.h

    r36659 r37068  
    2828#define ___VBox_com_mtlist_h
    2929
     30#include <VBox/com/ptr.h>
    3031#include <VBox/com/string.h>
    3132#include <iprt/cpp/mtlist.h>
     33
     34/**
     35 * Specialized thread-safe list class for using with com::ComPtr<C>
     36 *
     37 * @note: This is necessary cause ComPtr<IFACE> has a size of 8.
     38 */
     39template <typename C>
     40class RTCMTList< ComPtr<C> >: public RTCListBase< ComPtr<C>, ComPtr<C>*, true>
     41{
     42    /* Traits */
     43    typedef ComPtr<C>                 T;
     44    typedef T                        *ITYPE;
     45    static const bool                 MT = true;
     46    typedef RTCListBase<T, ITYPE, MT> BASE;
     47
     48public:
     49    /**
     50     * Creates a new list.
     51     *
     52     * This preallocates @a cCapacity elements within the list.
     53     *
     54     * @param   cCapacitiy   The initial capacity the list has.
     55     * @throws  std::bad_alloc
     56     */
     57    RTCList(size_t cCapacity = BASE::DefaultCapacity)
     58     : BASE(cCapacity) {}
     59
     60    /* Define our own new and delete. */
     61    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     62};
     63
     64/**
     65 * Specialized thread-safe list class for using with com::ComObjPtr<C>
     66 *
     67 * @note: This is necessary cause ComObjPtr<IFACE> has a size of 8.
     68 */
     69template <typename C>
     70class RTCMTList< ComObjPtr<C> >: public RTCListBase< ComObjPtr<C>, ComObjPtr<C>*, true>
     71{
     72    /* Traits */
     73    typedef ComObjPtr<C>              T;
     74    typedef T                        *ITYPE;
     75    static const bool                 MT = true;
     76    typedef RTCListBase<T, ITYPE, MT> BASE;
     77
     78public:
     79    /**
     80     * Creates a new list.
     81     *
     82     * This preallocates @a cCapacity elements within the list.
     83     *
     84     * @param   cCapacitiy   The initial capacity the list has.
     85     * @throws  std::bad_alloc
     86     */
     87    RTCList(size_t cCapacity = BASE::DefaultCapacity)
     88     : BASE(cCapacity) {}
     89
     90    /* Define our own new and delete. */
     91    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     92};
    3293
    3394/**
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