browserutilities/downloadmgr/DownloadMgrUiLib/Src/AsyncEventHandlerArray.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 the License "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:  Array of event handlers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "AsyncEventHandlerArray.h"
       
    22 #include    "UiLibLogger.h"
       
    23 #include    "DMgrUiLibPanic.h"
       
    24 
       
    25 // CONSTANTS
       
    26 const TInt32 KArrayGranularity = 6; // Let it as many THttpDownloadState is
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CAsyncEventHandlerArray::CAsyncEventHandlerArray
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CAsyncEventHandlerArray::CAsyncEventHandlerArray()
       
    35 :   CArrayPtrFlat<CAsyncEventHandlerBase>( KArrayGranularity ),
       
    36     iDestructing(0)
       
    37     {
       
    38     }
       
    39 
       
    40 // Destructor
       
    41 CAsyncEventHandlerArray::~CAsyncEventHandlerArray()
       
    42     {
       
    43     CLOG_ENTERFN("CAsyncEventHandlerArray::~CAsyncEventHandlerArray");
       
    44     // Delete all owned active object.
       
    45     iDestructing = ETrue;
       
    46     ResetAndDestroy();
       
    47     CLOG_LEAVEFN("CAsyncEventHandlerArray::~CAsyncEventHandlerArray");
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CAsyncEventHandlerArray::Remove
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CAsyncEventHandlerArray::Remove( CAsyncEventHandlerBase* aEventHandler )
       
    55     {
       
    56     CLOG_ENTERFN("CAsyncEventHandlerArray::Remove");
       
    57 
       
    58     if ( iDestructing )
       
    59         {
       
    60         // Do nothing. ResetAndDestroy() removes the elements.
       
    61         CLOG_WRITE(" Destructing");
       
    62         }
       
    63     else
       
    64         {
       
    65         TKeyArrayFix key(0,ECmpTInt32);
       
    66         TInt index(0);
       
    67         TInt err = Find( aEventHandler, key, index );
       
    68         CLOG_WRITE_FORMAT(" err: %d",err);
       
    69         if ( !err )
       
    70             {
       
    71             CLOG_WRITE_FORMAT(" index: %d",index);
       
    72             CArrayPtrFlat<CAsyncEventHandlerBase>::Delete( index );
       
    73             }
       
    74         }
       
    75 
       
    76     CLOG_LEAVEFN("CAsyncEventHandlerArray::Remove");
       
    77     }
       
    78 
       
    79 // End of file.