vtuis/videotelui/src/compman/tvtuiblocklists.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Component ID block lists implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "tvtuiblocklists.h"
       
    20 
       
    21 const static TUint KNullBlockMask = 0;
       
    22 
       
    23 // Implementation for TVtUiBlockList
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // TVtUiBlockList::~TVtUiBlockList
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 TVtUiBlockList::~TVtUiBlockList()
       
    30     {
       
    31     }
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // TVtUiBlockList::TVtUiBlockList
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 TVtUiBlockList::TVtUiBlockList()
       
    38     {
       
    39     }
       
    40 
       
    41 // Implementation for TVtUiBlockListBitField
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // TVtUiBlockListBitField::TVtUiBlockListBitField
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 TVtUiBlockListBitField::TVtUiBlockListBitField() : iBlockMask( KNullBlockMask )
       
    48     {
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // TVtUiBlockListBitField::TVtUiBlockListBitField
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 TVtUiBlockListBitField::TVtUiBlockListBitField( TUint aBlockMask )
       
    56     : iBlockMask( aBlockMask )
       
    57     {
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // TVtUiBlockListBitField::IsEmpty
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 TBool TVtUiBlockListBitField::IsEmpty() const
       
    65     {
       
    66     return !iBlockMask;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // TVtUiBlockListBitField::Contains
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 TBool TVtUiBlockListBitField::Contains( MVtUiComponent::TComponentId aId ) const
       
    74     {
       
    75     return ( iBlockMask & aId ) && ( aId != MVtUiComponent::EComponentIdNull );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // TVtUiBlockListBitField::Union
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void TVtUiBlockListBitField::Union( const TVtUiBlockList& aBlockList )
       
    83     {
       
    84     iBlockMask |=
       
    85         static_cast< const TVtUiBlockListBitField& >( aBlockList ).iBlockMask;
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // TVtUiBlockListBitField::IteratorLC
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CVtUiBlockListIterator* TVtUiBlockListBitField::IteratorLC() const
       
    93     {
       
    94     return TVtUiBlockListBitField::CVtUiBListIteratorBF::NewLC( iBlockMask );
       
    95     }
       
    96 
       
    97 // Implementation for TVtUiBlockListBitField::CVtUiBListIteratorBF
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // TVtUiBlockListBitField::CVtUiBListIteratorBF::NewLC
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TVtUiBlockListBitField::CVtUiBListIteratorBF*
       
   104 TVtUiBlockListBitField::CVtUiBListIteratorBF::NewLC(
       
   105     const TUint& aBlockMask )
       
   106     {
       
   107     CVtUiBListIteratorBF* self = new ( ELeave )
       
   108         CVtUiBListIteratorBF( aBlockMask );
       
   109     CleanupStack::PushL( self );
       
   110     return self;
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // TVtUiBlockListBitField::CVtUiBListIteratorBF::CVtUiBListIteratorBF
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 TVtUiBlockListBitField::CVtUiBListIteratorBF::CVtUiBListIteratorBF(
       
   118     const TUint& aBlockMask ) : iBlockMask( aBlockMask ), iCurrent( 1 )
       
   119     {
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // TVtUiBlockListBitField::CVtUiBListIteratorBF::HasNext
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TBool TVtUiBlockListBitField::CVtUiBListIteratorBF::HasNext() const
       
   127     {
       
   128     return ( iCurrent && ( iCurrent <= iBlockMask ) );
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // TVtUiBlockListBitField::CVtUiBListIteratorBF::Next
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 MVtUiComponent::TComponentId
       
   136 TVtUiBlockListBitField::CVtUiBListIteratorBF::Next()
       
   137     {
       
   138     MVtUiComponent::TComponentId id( MVtUiComponent::EComponentIdNull );
       
   139 
       
   140     while ( HasNext() && !( iCurrent & iBlockMask ) )
       
   141         {
       
   142         iCurrent <<= 1;
       
   143         }
       
   144 
       
   145     if ( iCurrent )
       
   146         {
       
   147         id = static_cast< MVtUiComponent::TComponentId >( iCurrent );
       
   148         }
       
   149 
       
   150 	iCurrent <<= 1;
       
   151 
       
   152     return id;
       
   153     }