wvuing/Utils/RCAPointerArray.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Wrapper for RPointerArray that destructs it's contents automatically
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef RCAPOINTERARRAY_H
       
    20 #define RCAPOINTERARRAY_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32cmn.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 /**
       
    28  *  Wrapper for RPointerArray.
       
    29  *	Destructs it's contents automatically.
       
    30  *
       
    31  *  @lib none
       
    32  *  @since Series 60 3.0
       
    33  */
       
    34 template <class T>
       
    35 class RCAPointerArray : public RPointerArray<T>
       
    36     {
       
    37     public:		// Constructors and destructor
       
    38 
       
    39         /**
       
    40          * C++ default constructor.
       
    41          */
       
    42         inline RCAPointerArray( TBool aOwnsItems = EFalse )
       
    43                 : iOwnsItems( aOwnsItems ) {};
       
    44 
       
    45         /**
       
    46          * Destructor.
       
    47          */
       
    48         inline virtual ~RCAPointerArray()
       
    49             {
       
    50             iOwnsItems ? RPointerArray<T>::ResetAndDestroy() : RPointerArray<T>::Close();
       
    51             }
       
    52 
       
    53     public: 	// new function
       
    54 
       
    55         /**
       
    56          * Set item ownership
       
    57          */
       
    58         inline void SetItemOwnership( TBool aOwnsItems )
       
    59             {
       
    60             iOwnsItems = aOwnsItems;
       
    61             }
       
    62 
       
    63     private:	// data
       
    64 
       
    65         TBool iOwnsItems;
       
    66 
       
    67     };
       
    68 
       
    69 #endif      // RCAPOINTERARRAY_H
       
    70 
       
    71 // End of File