javauis/amms_qt/module/src/cammsmodulecontainer.cpp
branchRCL_3
changeset 24 0fd27995241b
equal deleted inserted replaced
20:f9bb0fca356a 24:0fd27995241b
       
     1 /*
       
     2 * Copyright (c) 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:  Container for CAMMSModule objects.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <logger.h>
       
    21 
       
    22 #include "cammsmodulecontainer.h"
       
    23 
       
    24 // CONSTANTS
       
    25 // Before further testing is done, 4 is sufficient average value to be used here.
       
    26 const TInt KAMMSContainerDefaultGranularity = 4;
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // Destructor
       
    31 CAMMSModuleContainer::~CAMMSModuleContainer()
       
    32 {
       
    33     ResetAndDestroy();
       
    34 }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CAMMSModuleContainer::RemovePlayer
       
    38 // Removes player from all modules.
       
    39 // (other items were commented in a header).
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 void CAMMSModuleContainer::RemovePlayer(CMMAPlayer* aPlayer)
       
    43 {
       
    44     // Remove player from all modules
       
    45     for (TInt i = 0; i < Count(); i++)
       
    46     {
       
    47         At(i)->RemovePlayerNoStateCheck(aPlayer);
       
    48     }
       
    49 }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CAMMSModuleContainer::RemoveModule
       
    53 // Removes module from container.
       
    54 // (other items were commented in a header).
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CAMMSModuleContainer::RemoveModule(CAMMSModule* aModule)
       
    58 {
       
    59     // If the element is found, index is set to the position of that module
       
    60     // element within the array.
       
    61     TInt index = KErrNotFound;
       
    62 
       
    63     TKeyArrayFix key(0, ECmpTInt);   // offset = 0, type integer
       
    64 
       
    65     // find returns 0, if the element with the specified key is found. Non-zero
       
    66     // if the element with the specified key is not found
       
    67     TInt retVal = Find(aModule, key, index);
       
    68 
       
    69     LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSModuleContainer::DisposeModule find result %d",
       
    70               retVal);
       
    71 
       
    72     if (retVal == KErrNone)
       
    73     {
       
    74         // Remove the element by position. The module itself is not deleted
       
    75         // here, so it has to be deleted elsewhere if needed.
       
    76         Delete(index);
       
    77     }
       
    78     // else, module was not added to this container
       
    79 }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CAMMSModuleContainer::CAMMSModuleContainer
       
    83 // C++ default constructor can NOT contain any code, that
       
    84 // might leave.
       
    85 // -----------------------------------------------------------------------------
       
    86 CAMMSModuleContainer::CAMMSModuleContainer():
       
    87         CArrayPtrSeg< CAMMSModule >(KAMMSContainerDefaultGranularity)
       
    88 {
       
    89 }
       
    90 
       
    91 //  End of File